Skip to content

Instantly share code, notes, and snippets.

@varunvns
Last active November 25, 2017 14:27
Show Gist options
  • Save varunvns/400169cf77240cd89a9eafab65b8bb89 to your computer and use it in GitHub Desktop.
Save varunvns/400169cf77240cd89a9eafab65b8bb89 to your computer and use it in GitHub Desktop.
Add Website Binding to Hostfile
<#
.SYNOPSIS
This PowerShell Scrip Adds the website name given by the user to the Hosts file pointing to 127.0.0.1
Author: Varun Shringarpure
#>
Write-Host "Hosts File prior to adding the website binding"
Get-Content C:\Windows\System32\drivers\etc\hosts
Write-Host "Lets add the required binding to the Host File "
$websiteBindingName = Read-Host -Prompt 'Provide website binding to be added to the Hosts File:'
Add-Content -Path C:\Windows\System32\drivers\etc\hosts -Value "127.0.0.1 $websiteBindingName"
Write-Host "Hosts File after to adding the website binding"
Get-Content C:\Windows\System32\drivers\etc\hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment