I would like to retrieve a spefic network adapter configuration. When I do it with its DeviceID, it works well
Get-CimInstance -Query `
"Associators of {Win32_NetworkAdapter.DeviceID=3} Where ResultClass=Win32_NetworkAdapterConfiguration"
However, when I try with its NetConnectionID
Get-CimInstance -Query `
"Associators of {Win32_NetworkAdapter.NetConnectionID='External'} Where ResultClass=Win32_NetworkAdapterConfiguration"
this throw an invalid path error.
of, I could do this
Get-CimInstance -Query `
"Associators of {Win32_NetworkAdapter.DeviceID=$((Get-CimInstance -ClassName Win32_NetworkAdapter -Filter "NetConnectionID = 'External'").DeviceID)} Where ResultClass=Win32_NetworkAdapterConfiguration"
but the double Get-CimInstance
is actually not optimized
The goal is to renew a DHCP Lease for a specific named adapter
Get-CimInstance -Query `
"Associators of {Win32_NetworkAdapter.NetConnectionID='External'} Where ResultClass=Win32_NetworkAdapterConfiguration" |
Invoke-CimMethod -MethodName RenewDHCPLease
Thanks