In celebration of World IPv6 Day, I thought I’d post a little PowerShell code to return IP addresses for a computer. This information is stored in WMI with the Win32_NetworkAdapterConfiguration class. This class will return information about a number of virtual adapters as well so I find it easier to filter on the IPEnabled property.
The returned object has an IPAddress property which is an array of addresses. In here you will find IPv4 and IPv6 addresses. My quick and dirty script uses a relatively simple regular expression pattern to get those addresses.
In the Select-Object expression I’m defining custom properties to get the different IP addresses. Here’s what it looks like in action.
If you had a number of computers you could pipe the results to Where-Object and get just the IPv6 machines (or not).
Feel free to download Get-IP and try it out for yourself.