Hi Luc,
can you please modify line orange to get proper output ..
$cl=read-host "provide cluster name"
$cluster=get-cluster -name $cl
foreach ($e in (get-vmhost -Location $cluster))
{
$esxi=get-vmhost -name $e
$phyadapters=Get-VMHostNetworkAdapter -Physical -VMHost $esxi.name|select name,bitratepersec
[pscUSTOMoBJECT]@{
esxiname = $esxi.name
physicaladapters = ($phyadapters|Sort-Object -Unique) -join '|'
}
}
You have two options.
One row per ESXi node
$cluster=Get-Cluster -name $cl
foreach ($e in (Get-VMHost -Location $cluster))
{
$esxi=Get-VMHost -name $e
$phyadapters=Get-VMHostNetworkAdapter -Physical -VMHost $esxi.name | Sort-Object -Property Name -Unique
[PSCustomObject]@{
esxiname = $esxi.name
physicaladapters = $phyadapters.Name -join '|'
bitratepersec = $phyadapters.BitRatePerSec -join '|'
}
}
Or one row per pNIC
Get-Cluster -Name $cl -PipelineVariable cluster |
ForEach-Object -Process {
Get-VMHost -Location $cluster -PipelineVariable esx |
ForEach-Object -Process {
Get-VMHostNetworkAdapter -VMHost $esx -Physical | Sort-Object -Property Name |
ForEach-Object -Process {
[PSCustomObject]@{
esxiname = $esx.name
physicaladapters = $_.Name
bitratepersec = $_.BitRatePerSec
}
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You have two options.
One row per ESXi node
$cluster=Get-Cluster -name $cl
foreach ($e in (Get-VMHost -Location $cluster))
{
$esxi=Get-VMHost -name $e
$phyadapters=Get-VMHostNetworkAdapter -Physical -VMHost $esxi.name | Sort-Object -Property Name -Unique
[PSCustomObject]@{
esxiname = $esxi.name
physicaladapters = $phyadapters.Name -join '|'
bitratepersec = $phyadapters.BitRatePerSec -join '|'
}
}
Or one row per pNIC
Get-Cluster -Name $cl -PipelineVariable cluster |
ForEach-Object -Process {
Get-VMHost -Location $cluster -PipelineVariable esx |
ForEach-Object -Process {
Get-VMHostNetworkAdapter -VMHost $esx -Physical | Sort-Object -Property Name |
ForEach-Object -Process {
[PSCustomObject]@{
esxiname = $esx.name
physicaladapters = $_.Name
bitratepersec = $_.BitRatePerSec
}
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ahh its hash tabe so one key value pair is posible .thanks luc
i am also lookng to find configured speed property if yu can tell me where it is
That is a bit of special case.
As documented in PhysicalNic under the validLinkSpecification
Autonegotiate is not listed as one of the combinations supported. It is implicitly supported by the physical network adapter unless autoNegotiateSupported is set to false.
So we could do something like this
Get-Cluster -Name $cl -PipelineVariable cluster |
ForEach-Object -Process {
Get-VMHost -Location $cluster -PipelineVariable esx |
ForEach-Object -Process {
Get-VMHostNetworkAdapter -VMHost $esx -Physical | Sort-Object -Property Name |
ForEach-Object -Process {
[PSCustomObject]@{
esxiname = $esx.name
physicaladapters = $_.Name
bitratepersec = $_.BitRatePerSec
configuredspeed = if($_.ExtensionData.AutoNegotiateSupported){'Auto negotiate'}else{$_.ExtensionData.Spec.LinkSpeed.SpeedMb}
}
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference