Created
May 23, 2016 18:53
-
-
Save vadim-kovalyov/b02683fcba767176dd034cea9b7dea30 to your computer and use it in GitHub Desktop.
Creates a record in host file.
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
# | |
# Creates a record in host file. | |
# | |
function Register-Host | |
{ | |
param([string]$IpAddress = "127.0.0.1", [string]$Url) | |
$hostfile = "$env:SystemRoot\System32\drivers\etc\hosts" | |
$content = "$IpAddress $Url" | |
if(!(Get-Content $hostfile | Select-String $content -quiet)) | |
{ | |
Add-Content $hostfile $content | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment