Linking the network card to the Registry settings
An interesting problem from the forum. Get the IP enabled network adapters and read the associated registry keys to get the value of the NetLuidIndex.
$HKLM = 2147483650
$reg = [wmiclass]'\\.\root\default:StdRegprov'
$keyroot = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}"
$value = "NetLuidIndex"
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled='$true'" |
foreach {
$data = $_.Caption -split "]"
$suffix = $data[0].Substring(($data[0].length-4),4)
$key = $keyroot + "\$suffix"
$nli = $reg.GetDwordValue($HKLM, $key, $value) ## REG_DWORD
$nic = New-Object -TypeName PSObject -Property @{
Description = $_.Description
DeviceID = $_.Index
Suffix = $suffix
NetLuidIndex = $nli.uValue
}
$nic
} | Format-Table -AutoSize
Use the standard registry settings to read the HKLM hive and setup the WMI registry provider.
Get the network cards using a filter of IPEnabled = $true.
For each card break the caption property to get the subkey value and add it to the key root. Do a standard DWORD read on the registry and construct an object to display the results