Skip to content

Instantly share code, notes, and snippets.

@murpg
Created August 31, 2022 12:19
Show Gist options
  • Select an option

  • Save murpg/541bb15dcb802e04feed366305552b11 to your computer and use it in GitHub Desktop.

Select an option

Save murpg/541bb15dcb802e04feed366305552b11 to your computer and use it in GitHub Desktop.
This file gathers your local IP and adds an entry to your hosts file.
$ipV4 = Test-Connection -ComputerName (hostname) -Count 1 | Select -ExpandProperty IPV4Address
$localIP = $ipV4.IPAddressToString
$file = "C:\Windows\System32\drivers\etc\hosts"
$hostfile = Get-Content $file
$hostfile += "$localIP luceesite1.com"
$hostfile += "$localIP luceesite2.com"
Set-Content -Path $file -Value $hostfile -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment