Author Posts

July 10, 2017 at 5:39 pm

Hi, I've been struggling with this for about a week and I'm hoping someone one can share an example that I can build from. I'm trying to get the ip addresses of all active network adapters on a local computer and list them respectively (Wireless, VPN and Wired Connection). Thanks for any help in advance.

July 10, 2017 at 6:34 pm

I've only got the one operational adapter on mine. Try this. It's a little more elegant.
$NetAdapter = (Get-NetAdapter).where({$PSItem.Status -eq 'Up'})
(Get-NetIPAddress).where({$PSItem.InterfaceAlias -eq $NetAdapter.InterfaceAlias})

July 10, 2017 at 6:42 pm

Thanks but I cant get the Get-NetAdapter to work. The computers I work on are windows 7. Looks like that isn't available unless I upgrade to win 8.

July 10, 2017 at 6:48 pm

How about: (Get-WmiObject -Class Win32_NetworkAdapterConfiguration).where({$PSItem.IPAddress -ne $null})

July 11, 2017 at 11:31 am

Also, I just realized that the where method isn't available if you're on straight PowerShell 2, so here would be something more appropriate.

Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object IPAddress -ne $null

My bad.

July 11, 2017 at 1:32 pm

Thanks that definitely gets me closer. Is there a way to separate them or label them as wireless, wired, vpn?

July 11, 2017 at 2:04 pm

if you add sort description on the end

Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object IPAddress -ne $nul |sort description