PowerTip of the Day, from PowerShell.com
Sometimes it would be nice to be able to access network adapter configuration based on the name of that adapter as it appears in your Network and Sharing Center. To find the network configuration data for any network card with a "LAN" in its name, use this code:
Get-WmiObject Win32_NetworkAdapter -Filter 'NetConnectionID like "%LAN%"' | ForEach-Object { $_.GetRelated('Win32_NetworkAdapterConfiguration') }
If you want to further narrow this down and cover only NICs that are currently connected to the network, extend the WMI filter:
Get-WmiObject Win32_NetworkAdapter -Filter '(NetConnectionID like "%LAN%") and (NetConnectionStatus=2)' | ForEach-Object { $_.GetRelated('Win32_NetworkAdapterConfiguration') }
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.