In this post I will share a simple PowerCLI script which generates some Network Device information from your vSphere hosts. The information you’ll get is the vmHost name, device name, linkspeed and MAC address.
$vmHostNicInfo = @() foreach($vmHost in (Get-VMHost | Sort Name)){ foreach($nic in $vmhost.NetworkInfo.PhysicalNic){ $Details = "" | Select vmHost, Device,Linkspeed,Mac $Details.vmHost = $vmhost.Name $Details.Device = $nic.Extensiondata.Device $Details.Linkspeed = ($nic.Extensiondata.Linkspeed).SpeedMB $Details.Mac = $nic.Extensiondata.Mac $vmHostNicInfo += $Details } } $vmHostNicInfo | Format-Table -AutoSize
The output will look like this:![]()
But what if you only want to see the devices with a link speed lower then 1000? Well that’s possible with the following end line:
$vmHostNicInfo | Where {$_.Linkspeed -lt "1000"} | Format-Table -AutoSize
Or if you want to know which device/host belongs to a particular MAC address. You can use the following end line:
$vmHostNicInfo | Where {$_.Mac -eq "00:07:e9:1f:f9:bf"} | Format-Table -AutoSize
So with a small script, you’re able to export valuable data.
