PowerShell for Windows Admins

Mar 11 2012   11:22AM GMT

Setting a Network address in Windows Server 8

Richard Siddaway Richard Siddaway Profile: 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 -PrefixLength 24 -DefaultGateway

Set-DnsClientServerAddress -InterfaceAlias "Virtual Wireless" -ServerAddresses
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


 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: