Connect-VIServer MYVISERVER
$vmhosts = Get-VMHost | Get-View
foreach ($vmhost in $vmhosts)
{
$networkSystem = Get-view $vmhost.ConfigManager.NetworkSystem
Write-Host $vmhost.Name -foregroundcolor yellow
foreach($netSys in $networkSystem)
{
foreach($pnic in $netSys.NetworkConfig.Pnic)
{
$subnets = $netSys.QueryNetworkHint($pnic.Device)
foreach($pnicHint in $subnets)
{
Write-Host $pnicHint.Device
foreach($pnicIpHint in $pnicHint.Subnet)
{
Write-Host "`t" $pnicIpHint.IpSubnet
}
}
}
}
}
Recently I needed to check a whole bunch of servers to see if we had a particular VLAN tagged on any of the ESX Hosts, after a quick post on the VI Toolkit forum and a little messing, the following script tells me quickly which observed IP ranges are on each of the nics in each of the hosts...