Hot Shot
Hot Shot

getting physicl nic speed _powercli

Jump to solution

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 '|'

                }

}

0 Kudos
1 Solution

Accepted Solutions
Leadership
Leadership

You have two options.

One row per ESXi node

$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 | Sort-Object -Property Name -Unique

    [PSCustomObject]@{

        esxiname = $esxi.name

        physicaladapters = $phyadapters.Name -join '|'

        bitratepersec = $phyadapters.BitRatePerSec -join '|'

    }

}

Or one row per pNIC

$cl=Read-Host "provide cluster name"

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

View solution in original post

0 Kudos
4 Replies
Leadership
Leadership

You have two options.

One row per ESXi node

$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 | Sort-Object -Property Name -Unique

    [PSCustomObject]@{

        esxiname = $esxi.name

        physicaladapters = $phyadapters.Name -join '|'

        bitratepersec = $phyadapters.BitRatePerSec -join '|'

    }

}

Or one row per pNIC

$cl=Read-Host "provide cluster name"

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

View solution in original post

0 Kudos
Hot Shot
Hot Shot

ahh its hash tabe so one key value pair is posible .thanks luc

0 Kudos
Hot Shot
Hot Shot

i am also lookng to find configured speed property if yu can tell me where it is

pastedImage_0.png

0 Kudos
Leadership
Leadership

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

$cl=Read-Host "provide cluster name"

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

0 Kudos