Setting a Network address in Windows Server 8
Posted by: Richard Siddaway
Windows Server 8 & Windows 8 bring a host of new functionality to us. I wanted to try out some of it so created a new VM and installed the OS – went for full GUI for now
Opened PowerShell and ran
Set-ExecutionPolicy remotesigned
Enable-PSRemoting -Force
The NetTCPIP module has some commands for working with network addresses
Get-NetIPInterface -ConnectionState Connected
ifIndex ifAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp Store
——- ——- ————- ———— ————— —- —–
21 Virtual Wireless IPv6 1500 5 Disabled Active
12 Virtual LAN IPv6 1500 5 Disabled Active
21 Virtual Wireless IPv4 1500 5 Disabled Active
12 Virtual LAN IPv4 1500 5 Disabled Active
The display is abridged to fit
The important points are the ifIndex and ifAlias. The index scheme is totally different to the Win32_NetworkAdapter* scheme
To set the address
New-NetIPAddress -InterfaceAlias "Virtual Wireless" -IPv4Address 192.168.2.10 -PrefixLength 24 -DefaultGateway 192.168.2.1
Set-DnsClientServerAddress -InterfaceAlias "Virtual Wireless" -ServerAddresses 192.168.2.1
Set-DnsClient -InterfaceIndex 21 -ConnectionSpecificSuffix beta8.test
Notice that you have to use New-NetIPAddress. The logic seems to be that you are adding a new address to the adapter so use New*.
Set-NetIPAddress works to modify an existing address BUT you can’t change the default gateway that way!
The Set-DnsClient* cmdlets are in the DnsClient module
All of these cmdlets are based on calls to WMI classes
At the end of all that I wanted to bounce the machine any way so used
Restart-Computer




