-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet-HostValue.ps1
More file actions
31 lines (29 loc) · 942 Bytes
/
Set-HostValue.ps1
File metadata and controls
31 lines (29 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<#
.SYNOPSIS
Set values in the hosts file so tests will work since domain name is used in auth callback
#>
[CmdletBinding(SupportsShouldProcess)]
param(
[string] $TestWebServer = "cmbootcamptestweb.clear-measure.com",
[string] $StagingWebServer = "cmbootcampstagingweb.clear-measure.com"
)
Set-StrictMode -Version Latest
$fname = (Join-Path $env:windir "system32\drivers\etc\hosts" )
$hosts = Get-Content $fname -Raw
$saveIt = $false
if ( !$hosts.Contains($TestWebServer) )
{
$hosts += "`r`n# added for Bootcamp testing`r`n127.0.0.1 $TestWebServer`r`n"
LogIt "Adding $TestWebServer to hosts file"
$saveIt = $true
}
if ( !$hosts.Contains($StagingWebServer) )
{
$hosts += "`r`n# added for Bootcamp testsing`r`n127.0.0.1 $StagingWebServer`r`n"
LogIt "Adding $StagingWebServer to hosts file"
$saveIt = $true
}
if ( $saveIt -and $PSCmdlet.ShouldProcess($fname, "Add mappings" ) )
{
Set-Content $fname -Value $hosts
}