PowerShell for Windows Admins

Jan 18 2012   1:18PM GMT

Associated Classes

Richard Siddaway Richard Siddaway Profile: Richard Siddaway


If I run

Get-WmiObject -Class Win32_NetworkAdapter

I get a list of the Network Adapters in my system plus some information about the adapter.  What I don’t get is the IP addressing and other configuration information because it is stored on the Win32_NetworkAdapterConfiguration class.

The key property on Win32_NetworkAdapter is DeviceId.  My wireless card is DeviceId 11.

There is an association between the Win32_NetworkAdapter class and the corresponding Win32_NetworkAdapterConfiguration class. The Win32_NetworkAdapterConfiguration  class uses Index to identify the card and

Win32_NetworkAdapter.DeviceId = Win32_NetworkAdapterConfiguration.Index

So I could  do this

Get-WmiObject -Class Win32_NetworkAdapter -Filter “DeviceID=11”

Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter “Index=11”

A better way is work through the association

$nic = Get-WmiObject -Class Win32_NetworkAdapter -Filter “DeviceID=11”
$q = “ASSOCIATORS OF {Win32_NetworkAdapter.DeviceID=$($nic.DeviceID)} WHERE ResultClass = Win32_NetworkAdapterConfiguration”
Get-WmiObject -Query $q

I tend to use WQL but there is an alternative

$nic = Get-WmiObject -Class Win32_NetworkAdapter -Filter “DeviceID=11”

The WMI object has a GetRelated() method

if you just do


you will get all associations – its the equivalent of

$q = “ASSOCIATORS OF {Win32_NetworkAdapter.DeviceID=$($nic.DeviceID)} ”
Get-WmiObject -Query $q

One slight problem is that if you do

$nic | Get-Member

you won’t see the method – you will need to do this

$nic | Get-Member -View base

Which one should you use? Its your choice. I tend to use WQL out of habit but GetRelated() is less typing.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: