Manage Network Adapters with PowerShell: Configure an Adapter

Posted on July 31, 2013 by Jeff Hicks in Networking with 0 Comments

Over my last few articles I’ve been demonstrating how to use PowerShell to manage network adapters in Windows Server 2012 (and since the code base is the same – though to a lesser degree – Windows 8 adapters as well). To this point I’ve shown you how to gather a lot of information. In this article let’s start on how to configure an adapter. I hope it goes without saying, but don’t forget that some changes might not take effect until we restart the adapter, and network connections could be interrupted. So test everything in a non-production environment first.

This is part four of a multi-part series. I’ve already covered how to manage network adapters with PowerShell and how to configure network adapters in Windows Server 2012. And in part three, I went over how to troubleshoot some networking issues using PowerShell cmdlets.

Manage Network Adapters with PowerShell: Using Set-NetAdapter

The Set-NetAdapter cmdlet is part of the NetAdapter module. You can specify an adapter by name, interface description, or pipe an adapter from Get-NetAdapter. You primarily can use this cmdlet to set the adapter’s VLAN ID (if supported) or the MAC address. The cmdlet even supports –WhatIf

I ran this command from my Windows 8 admin desktop. The remote adapter will most likely automatically restart when you make a change. But you can include –NoRestart to defer this operation. If you need to manually restart the adapter, use a command like this:

As you can see in Figure 1 below, this kills the network connection, but PowerShell 3.0 attempts to re-establish it.

manage network adapter with PowerShell: setadapter

Sponsored

It is also possible to completely disable and enable network adapters.

You’ll be prompted for confirmation. As before, PowerShell will attempt to reconnect, but since the remote adapter is offline, this should eventually fail.

manage network adapter with PowerShell: setadapter

Of course, I’ll have to be on the remote computer to re-enable it if there is only a single adapter.

Set-NetAdapterAdvancedProperty

I would expect advanced properties to fall under the special exception category. Using Set-NetAdapterAdvancedProperty you should be able to set any of the settings you see in Figure 3.

manage network adapter with PowerShell: Set-NetAdapterAdvancedProperty

For example, let’s say I want to enable support for jumbo packets on the adapter in CHI-FP02. I can use a command like this:

Because the server only has a single adapter, this command should work just fine. Otherwise I would need to come up with a query using Get-NetAdapter or use the –Name property from Set-NetAdapterAdvancedProperty to set the correct one. And here’s a tip: If you aren’t sure what the correct value is for the display value, use a bogus value like FOO and the exception message should indicate the acceptable values. You can see my results in Figure 4.

manage network adapter with PowerShell: Set-NetAdapterAdvancedProperty

Sponsored

And of course what I can do for one I can do for many, as long as the remote computers are running Windows Server 20121 or later. Figure 5 shows the Jumbo Packet settings for a few computers.

manage network adapter with PowerShell: Set-NetAdapterAdvancedProperty

Now I can modify the setting on all of them with a single command.

This may take a little time to complete as the adapter is getting reset on each computer. Or I could have used –NoRestart. My results can be seen in Figure 6.

manage network adapter with PowerShell: setadapter

Set-NetAdapterBinding

The last item you might need to set is adapter binding. By that I mean protocols and services like QoS, File and Print Sharing, and IPv6. You can see them with Get-NetAdapterBinding. Figure 7 displays some settings on a few servers that I want to change.

manage network adapter with PowerShell: Set-NetAdapterBinding

I can disable these with Set-NetAdapterBinding.

Just like that, these bindings have been disabled as you see in Figure 8.

manage network adapter with PowerShell: Set-NetAdapterBinding

Seriously, I don’t see how this could get any easier.

What I’ve shown you is by no means all that you can do with these cmdlets. As with all PowerShell articles, be sure to read full help and examples. In the next article we’ll look at some additional configuration options.

Sponsored

Tagged with , ,