Thanks LuCD for the quick reply.
i have removed the first line "$esxName = 'MyEsx'" as i require all the esxi hosts in the vCenter, so i have connected the vCenter server directly and run the below
Get-View -ViewType HostSystem -Filter @{Name=$esxName} -PipelineVariable esx |
ForEach-Object -Process {
$netSys = Get-View -Id $esx.ConfigManager.NetworkSystem
foreach($vss in $netSys.NetworkInfo.Vswitch){
foreach($nic in $vss.Pnic){
$netSys.NetworkInfo.Pnic | where{$_.Key -eq $nic} |
Select @{N='VMHost';E={$esx.Name}},
@{N='Switch';E={$vss.Name}},
@{N='SwitchType';E={'VSS'}},
@{N='pNic';E={$_.Device}},
@{N='SpeedMB';E={$_.LinkSpeed.SpeedMB}},
@{N='Duplex';E={$_.LinkSpeed.Duplex}},
@{N='Status';E={if($_.LinkSpeed -eq $null){'Down'}else{'Up'}}}
}
}
foreach($vds in $netSys.NetworkInfo.ProxySwitch){
foreach($nic in $vds.Spec.Backing.PnicSpec){
$netSys.NetworkInfo.Pnic | where{$_.Device -eq $nic.PnicDevice} |
Select @{N='VMHost';E={$esx.Name}},
@{N='Switch';E={$vds.DvsName}},
@{N='SwitchType';E={'VDS'}},
@{N='pNic';E={$_.Device}},
@{N='SpeedMB';E={$_.LinkSpeed.SpeedMB}},
@{N='Duplex';E={$_.LinkSpeed.Duplex}},
@{N='Status';E={if($_.LinkSpeed -eq $null){'Down'}else{'Up'}}}
}
}
}
It would be very helpful how how to get the network status report for all the esxi hosts in the vCenter server with formatted table.
I have tried below using esxcli v2 in simple format but didnt get the host name and formatted output what exactly i am looking.
$EsxHosts = Get-VMHost
foreach($EsxHost in $EsxHosts){
$esxcli = Get-VMHost $EsxHost | Get-EsxCli -V2
$esxcli.network.nic.list.Invoke()
}
Thank you
Regards
Narayanan.