Hi ,
I am new to powercli. I am looking for a script which can give me the information of the physical switch which is connected with the esxi host
Thanks in advance.
I assume you are referring to the QueryNetworkHint method to get the physical switch information ?
To see if I got the question right, you want to
Is that correct ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
$clusterName = 'MyCluster'
$cluster = Get-Cluster -Name $clusterName
foreach($esx in Get-VMHost -State Connected -Location $cluster){
$netSys = Get-View -Id $esx.ExtensionData.ConfigManager.NetworkSystem
$esxcli = Get-EsxCli -VMHost $esx
foreach($vds in Get-VDSwitch -VMHost $esx){
foreach($pnic in ($esxcli.network.vswitch.dvs.vmware.list($vds.Name) | Select -ExpandProperty Uplinks)){
$netSys.QueryNetworkHint($pnic) |
Select @{N='Cluster';E={$cluster.Name}},
@{N='VMHost';E={$esx.Name}},
@{N='VDS';E={$vds.Name}},
@{n='pNIC';E={$pnic}},
@{N='MgmtIP';E={$_.LLDPInfo.Parameter | where{$_.Key -eq 'Management Address'} | Select -ExpandProperty Value}},
@{N='PortDesc';E={$_.LLDPInfo.Parameter | where{$_.Key -eq 'Port Description' } | Select -ExpandProperty Value}},
@{N='SysDesc';E={$_.LLDPInfo.Parameter | where{$_.Key -eq 'System Description' } | Select -ExpandProperty Value}},
@{N='SysName';E={$_.LLDPInfo.Parameter | where{$_.Key -eq 'System Name' } | Select -ExpandProperty Value}}
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Again @LucD.
I will let you know the result. Let me try it 🙂