Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@toddb
Created August 10, 2011 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddb/1138154 to your computer and use it in GitHub Desktop.
Save toddb/1138154 to your computer and use it in GitHub Desktop.
Update host file in psake
Property {
$domain = ""
}
Task Hostfile-Update -Description "Add new sites to the host file" {
$host_file = "$env:windir\System32\drivers\etc\hosts"
if ((Get-Content $host_file | ForEach-Object{$_ -eq "127.0.0.1 $domain "}) -notcontains "True")
{
Add-Content $host_file "`n127.0.0.1 $domain "
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment