Skip to content

Instantly share code, notes, and snippets.

@R41D3NN
Created April 18, 2018 15:00
Show Gist options
  • Save R41D3NN/401bc1bcb95701d8a875147f231685cb to your computer and use it in GitHub Desktop.
Save R41D3NN/401bc1bcb95701d8a875147f231685cb to your computer and use it in GitHub Desktop.
Creates a Hyper-V NAT'd internal switch.
$switchName = "my.local"
New-VMSwitch -SwitchName $switchName -SwitchType Internal
$netAdapter = Get-NetAdapter | Where -Property Name -Eq "vEthernet ($switchName)"
New-NetIPAddress -IPAddress 10.0.0.1 -PrefixLength 24 -InterfaceIndex $netAdapter.ifIndex
New-NetNat -Name "$switchName-NAT" -InternalIPInterfaceAddressPrefix 10.0.0.0/24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment