Mailbag: How do you set network adapter settings with PowerShell in Windows 8 or Windows Server 2012?



AskPFEPlat is in the process of a transformation to the new Core Infrastructure and Security TechCommunity, and will be moving by the end of March 2019 to our new home at (hosted at Please bear with us while we are still under construction!

We will continue bringing you the same great content, from the same great contributors, on our new platform. Until then, you can access our new content on either as you do today, or at our new site Please feel free to update your bookmarks accordingly!

Why are we doing this? Simple really; we are looking to expand our team internally in order to provide you even more great content, as well as take on a more proactive role in the future with our readers (more to come on that later)! Since our team encompasses many more roles than Premier Field Engineers these days, we felt it was also time we reflected that initial expansion.

If you have never visited the TechCommunity site, it can be found at On the TechCommunity site, you will find numerous technical communities across many topics, which include discussion areas, along with blog content.

NOTE: In addition to the AskPFEPlat-to-Core Infrastructure and Security transformation, Premier Field Engineers from all technology areas will be working together to expand the TechCommunity site even further, joining together in the technology agnostic Premier Field Engineering TechCommunity (along with Core Infrastructure and Security), which can be found at!

As always, thank you for continuing to read the Core Infrastructure and Security (AskPFEPlat) blog, and we look forward to providing you more great content well into the future!


Here’s an interesting question that came to us from one of our readers. If you have a question for us, don’t forget that you can contact us using the Contact tile just to the right of this article when viewed from our TechNet blog.


I am setting up multiple Windows Server 2012 and Windows 8 virtual machines.  How do you set the IP address of a network adapter using PowerShell?

This is a great question.  It makes sense to be able to automate parts of the virtual machine configuration process, especially when creating multiple virtual machines for a virtual lab environment.  While these commands can be pasted into a PowerShell prompt from the Clipboard functions of a Virtual Machine Connection, these could be slipped into the OS install with other tools as well for a more automated experience.  The PowerShell commands referenced below may be used with Windows Server 2012 and Windows 8.  These commands don’t just work within virtual machines.  They work with installations to physical hardware as well.

To configure network adapters in Windows Server 2012 or Windows 8 using PowerShell, you first need to know the names of the network adapters as you would see them in the list of network connections if you were to look.  The default name for a network connection in Windows Server 2012 or Windows 8 is Ethernet. .  If you’ve installed Windows Server 2012 or Windows 8 with just a single network adapter, then the only name you need to be concerned with is Ethernet.  If there are other network adapters detected by this operating system, those will be sequentially numbered starting with Ethernet 2, and so on.  For this example, let’s assume a configuration of two adapters with the following intended IP address configuration:

“Ethernet” IP Address

Subnet Mask

Default Gateway


“Ethernet 2” IP Address

Subnet Mask

Default Gateway





The following commands may be used to configure the network adapters based on the configuration above:


$netadapter = Get-NetAdapter -Name Ethernet

$netadapter | Set-NetIPInterface -Dhcp Disabled

$netadapter | New-NetIPAddress -IPAddress -PrefixLength 24 –DefaultGateway

Set-DnsClientServerAddress -InterfaceAlias “Ethernet” -ServerAddresses “


$netadapter = Get-NetAdapter -Name “Ethernet 2”

$netadapter | Set-NetIPInterface -Dhcp Disabled

$netadapter | New-NetIPAddress -IPAddress -PrefixLength 8


Using IPConfig /all, you can see the results of these commands:



If you wanted later to change Ethernet 2 back to DHCP addressing, it is as easy as omitting the New-NetIPAddress calls and changing the –DHCP parameter of Set-NetIPInterface to Enabled.


$netadapter = Get-NetAdapter -Name “Ethernet 2”

$netadapter | Set-NetIPInterface -Dhcp Enabled



For more details about the New-NetIPAddress PowerShell cmdlet for Windows 8 and Windows Server 2012, as well as links to other related cmdlets you may find valuable, please consult the following reference:

Also, when configuring virtual machines, the Metrics setting can be important.  For more information about the importance of Metrics setting on the network adapters, check out Roger’s post below:

Until next time!