This Oneliner is broken into mutiple lines for ease of use. But it can be condensed to ONE LINE. Yehaw!
Get-view -ViewType HostSystem -Filter @{"Name"="$VMhost"} -Property ConfigManager.NetworkSystem, Name | sort name | % { $n=$_.name ; $objConfigManager_NetworkSystem = get-view $_.ConfigManager.NetworkSystem ; $objConfigManager_NetworkSystem | % { $_.NetworkInfo } | % { $_.Pnic } | SELECT @{N="Name"; E={$n} } , device, pci, mac, @{N="PortID" ; E= { $objConfigManager_NetworkSystem.QueryNetworkHint($_.Device) | % { $_.ConnectedSwitchPort.PortID } } }, @{N="DevID" ; E= { $objConfigManager_NetworkSystem.QueryNetworkHint($_.Device) | % { $_.ConnectedSwitchPort.DevID } } } | ? { $_.Device -match "vmnic" }
}
Output Example:
Name | Device | PCI | MAC | PortID | DeviceID | |
esxhstesx01.us.ano.net | vmnic0 | 01:00.0 | 00:34:84:5d:75:a4 | GigabitEthernet2/0/9 | C3750x.phx.az.anon.com | |
esxhstesx01.us.ano.net | vmnic1 | 01:00.1 | 00:23:44:5d:75:a6 | GigabitEthernet1/0/11 | C3750x.phx.az.anon.com | |
esxhstesx01.us.ano.net | vmnic2 | 04:00.0 | 00:43:33:90:77:78 | GigabitEthernet2/0/11 | C3750x.phx.az.anon.com | |
esxhstesx01.us.ano.net | vmnic3 | 04:00.1 | 00:77:33:90:77:79 | GigabitEthernet1/0/9 | C3750x.phx.az.anon.com |
No comments:
Post a Comment