The Get-CimAssociatedClass command replaces the use of the ASSOCIATORS OF query type when using the CIM cmdlets.
The following command gets the class instances associated with Win32_NetworkAdapterConfiguration. As the arguments for the Get-CimInstance command are long strings, splatting is used to pass the parameters into the command:
$params = @{ ClassName = 'Win32_NetworkAdapterConfiguration' Filter = 'IPEnabled=TRUE AND DHCPEnabled=TRUE' } Get-CimInstance @params | Get-CimAssociatedInstance
The following example uses Get-CimAssociatedClass to get the physical interface associated with the IP configuration:
$params = @{ ClassName = 'Win32_NetworkAdapterConfiguration' Filter = 'IPEnabled=TRUE AND DHCPEnabled=TRUE' } Get-CimInstance @params | ForEach-Object { $adapter = $_ | Get-CimAssociatedInstance -ResultClassName Win32_NetworkAdapter [PSCustomObject]@{ NetConnectionID = $adapter.NetConnectionID Speed = [Math]::Round($adapter.Speed / 1MB, 2) IPAddress = $_.IPAddress IPSubnet = $_.IPSubnet Index = $_.Index Gateway = $_.DefaultIPGateway } }