Skip to content

Instantly share code, notes, and snippets.

@vadim-kovalyov
Created May 23, 2016 18:53
Show Gist options
  • Save vadim-kovalyov/b02683fcba767176dd034cea9b7dea30 to your computer and use it in GitHub Desktop.
Save vadim-kovalyov/b02683fcba767176dd034cea9b7dea30 to your computer and use it in GitHub Desktop.
Creates a record in host file.
#
# 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