VMware Cloud Community
jvm2016
Hot Shot
Hot Shot
Jump to solution

getting physicl nic speed _powercli

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

                }

}

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

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

pastedImage_0.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos