header image

WMI Associations

Posted by: | October 13, 2014 Comments Off on 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

under: CIM, PowerShell and WMI

Comments are closed.