You will find that many WMI classes have links – some are associations built in to WMI (a subject for another time) while other classes can be linked based on property values. An example of the latter is the Win32_NetworkAdapter and Win32_NetworkAdapterConfiguration classes. The DeviceId on Win32_NetworkAdapter matches Index on Win32_NetworkAdapterConfiguration .
The follwoing function (adapted from a question on the forum) shows one way this link can be used
function Get-NetworkInfo{
[cmdletbinding()]
param( [string]$ComputerName )
$networkinfo = @()
$networks = Get-WmiObject Win32_Networkadapter -Filter ‘NetEnabled=True’ -ComputerName $ComputerName
$adapter = 0
foreach($network in $networks){
$id = $network.DeviceId
$IPinfo = Get-WmiObject win32_networkadapterconfiguration -Filter “Index = $id” -ComputerName $ComputerName
$winServers = 0
$winServers = ($IPinfo.WinsPrimaryServer -join ‘,’),($IPinfo.WinsSecondaryServer -join ‘,’)
$adapter += 1
$props = @{
‘Adapter’ = $adapter;
‘Manufacturer’ = $network.Manufacturer;
‘Description’ = $network.Description;
‘Connection’ = $network.NetConnectionID;
‘SpeedGB’ = [math]::Round($network.Speed / 1GB, 2)
‘IPAddress’ = $IPinfo.IPAddress -join ‘,’
‘Submask’ = $IPinfo.IPSubnet -join ‘,’
‘Gateway’ = $IPinfo.DefaultIPGateway -join ‘,’
‘DNSServers’ = $IPinfo.DnsServerSearchOrder-join ‘,’
‘WinServers’ = $winServers -join ‘,’
‘DomainSuffixes’ = $IPinfo.DNSDomainSuffixSearchOrder -join ‘,’
}
$networkinfo += New-Object -TypeName psobject -Property $props
}
$networkinfo
}
Get-NetworkInfo -ComputerName $env:COMPUTERNAME