Created
July 20, 2018 19:16
-
-
Save ssougnez/62d934241e264c0c7ff622a2e952fd0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function EnsureHostEntry { | |
Param([string]$ip, [string]$hostName) | |
$hostFilename = "C:\Windows\System32\drivers\etc\hosts" | |
[array]$content = [System.IO.File]::ReadAllLines($hostFilename, [System.Text.Encoding]::ASCII) | Select-String $hostName -NotMatch | |
$content += $("{0}`t`t{1}" -f $ip, $hostName); | |
[System.IO.File]::WriteAllLines($hostFilename, $content, [System.Text.Encoding]::ASCII) | |
Success | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment