Finding Network Adapter Data Based On Connection Name

by Nov 23, 2011

Sometimes it would be nice to be able to access network adapter configuration based on the name of that adapter as it appears in your network and sharing center. To find the network configuration data for any network card with a "LAN" in its name, use this code:

Get-WmiObject Win32_NetworkAdapter -Filter 'NetConnectionID like "%LAN%"' |   ForEach-Object { $_.GetRelated('Win32_NetworkAdapterConfiguration') }

If you want to further narrow this down and cover only NICs that are currently connected to the network, extend the WMI filter:

Get-WmiObject Win32_NetworkAdapter -Filter '(NetConnectionID like "%LAN%") and (NetConnectionStatus=2)' |   ForEach-Object { $_.GetRelated('Win32_NetworkAdapterConfiguration') }

Twitter This Tip!
ReTweet this Tip!