Getting network interface device name in powershell
- by Grant
I needed a powershell 2 script to get the name and device name of each interface like it is shown in network connections in control panel.
Should be easy...
$interfaces = Get-WmiObject Win32_NetworkAdapter
$interfaces | foreach {
$friendlyname = $_ | Select-Object -ExpandProperty NetConnectionID
$name = $_ | Select-Object -ExpandProperty Name
}
However, $name comes back as "Broadcom BCM5709C NetXtreme II GigE (NDIS VBD Client)", whereas in control panel it shows "Broadcom BCM5709C NetXtreme II GigE (NDIS VBD Client) #69", because there are multiple cards. I can't find that number anywhere in the properties.
How can I get both the Name and Device Name, exactly as shown in Network Connections, in powershell 2 on windows server 2008 r2?