WMI Associations


I saw a question regarding finding the Win32_NetworkAdapter instance using the matching Win32_NetworkAdapterConfiguration starting point.  This answers the “which adapter has an IP address of X” type question.


The Index property on a Win32_NetworkAdapterConfiguration instance has the same value as the DeviceId property on the corresponding Win32_NetworkAdapter.


An alternative is to use the ASSOCIATORS WQL keyword.


That approach get s a bit messy but looks like this:


$query = “ASSOCIATORS OF {Win32_NetworkAdapterConfiguration.Index=’18’} WHERE RESULTCLASS = Win32_NetworkAdapter”
Get-WmiObject -Query $query


The CIM cmdlets get a bit better


$config = Get-CimInstance win32_networkadapterconfiguration -Filter “Index = 18”
Get-CimAssociatedInstance -InputObject $config -ResultClassName Win32_NetworkAdapter


Much simpler and you avoid the WQL

This entry was posted in CIM, PowerShell and WMI. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s