Petri

Managing Network Adapters with PowerShell: Addressing and Configuration Info

In my previous article, we started exploring working with network adapters in Windows Server 2012 using PowerShell. In that article, we looked at getting information from the physical adapter. Today let’s get some addressing and configuration information. As before, I’m running PowerShell 3 in a Windows 8 desktop that has RSAT (Remote Server Administration Tools) installed in a domain setting. The commands can be used remotely, but the server must be running Windows Server 2012 or later. Finally, in part three of this series I’ll explore PowerShell cmdlets that might come in handy when troubleshooting a networking issue.

Managing Network Adapters: Get-NetIPInterface

First, I want to track down interface information for a remote server

Results are displayed below in Figure 1.

Get-NetIPInterface

Since I’m not using IPv6 in my network, let me focus only on IPv4.

Figure 2 displays an easier-to-read result.

Get-NetIPInterface

If I can do this for one, I can do it for many. Since I’m going to be querying remote machines more than once, I’ll go ahead and create some CIMSessions that I can reuse.

Now I’ll repeat my previous command for all the computers and filter out the loopback adapters. But I’ll also need to tweak it to show the computer name.

This will give me a nice list displayed in a sortable and filterable grid.

Get-NetIPInterface

The interface index can come in handy when using the next cmdlets if a server has multiple adapters and you want to limit your query. I don’t have the situation in my test domain.

Getting More Info with Get-NetIPAddress

Based on the preceding, I can get an idea of the TCPIP configuration for each adapter. But I want more information, so I’ll turn to Get-NetIPAddress, focusing on IPv4 addresses.

I want to re-use an existing CIMSession I’ve already created for CHI-APP01. You can see my results below in Figure 4.

Get-NetIPAddress

I don’t really need to know about the loopback adapter, so I’ll filter it out. As before, I grab IPv4 address configuration for multiple servers.

I know this seems like a lot to type – and if you need to do this on a regular basis, you’ll definitely want to turn this command into a script or function. Figure 5 illustrates the result.

Get-NetIPAddress

Many of the cmdlets I’m demonstrating are designed to work together. I could also have used my earlier command getting IP Interface objects and pipe them to Get-NetIPAddress.

 

Get-NetIPAddress

This is sort of like running IPConfig remotely – plus, we get objects.

 

More Details with Get-NetIPConfiguration

Actually, we can more details on IP Configuration using Get-NetIPConfiguration. I think of this cmdlet as the IPCONFIG PowerShell equivalent.

Although the major benefit to the cmdlet is that it can query a remote computer.

Or you can get detailed configuration information.

 

Get-NetIPConfiguration

Querying remote computers is a little different, as the –CimSession parameter for Get-NetIPConfiguration won’t accept an array of sessions. However, you can pipe a CIMSession to the cmdlet.

 

 

Get-NetIPConfiguration

Where it gets difficult is selecting the properties to display in gridview, export to a CSV, or build an HTML report. This is because many of the properties are themselves nested CIMInstances. The shell automatically unrolls everything when displaying to the console as I’ve done above. But anything else takes a little more work.

This is definitely something you would want to script. But now I can run my CIMSessions through this and then to Out-Gridview, as you can see in Figure 9.

 

Get-NetIPConfiguration

Based on this, I can see I need to make some configuration changes to a few servers. We’ll look at that in a future article.

As with everything I show you in PowerShell, be sure to read the full help and examples because I am not demonstrating every parameter and use case. I know it looks like a lot of typing, but most of the time that was because I wanted some specific information. If you are happy with the default console output, it doesn’t take much work to get network adapter information from Windows Server 2012 with PowerShell.

Next time we’ll look at some other information we can gather remotely.

Tagged , ,

Join The Conversation

Sponsors

Sponsors