PowerCLI

 View Only
  • 1.  List configured Speed of Physical adapter of ESXi

    Posted Jan 05, 2022 10:37 AM

    Hello,

    I try to get the ESXi Physical adapter status of Configured Speed in a script with an ouput file but the column ConfiguredSpeed didn't generate.

    This a part of my script:

    Select @{N='VMHost';E={$esx.Name}},

    @{N='ConfiguredSpeed';E={
    if ($_.ExtensionData.AutoNegotiateSupported)
    {'Auto negotiate'} else {$_.ExtensionData.Spec.LinkSpeed.SpeedMb}}},

    Regards,

    David



  • 2.  RE: List configured Speed of Physical adapter of ESXi

    Posted Jan 05, 2022 10:48 AM

    Without telling us what is in $_ it is hard to analyse



  • 3.  RE: List configured Speed of Physical adapter of ESXi

    Posted Jan 05, 2022 10:51 AM

    Hello Luc,

    You're right I give you additionnal information:

    ForEach-Object -Process {

    $esxcli = Get-EsxCli -VMHost $esx -V2

    $esxcli.network.vswitch.standard.list.Invoke() |

    ForEach-Object -Process {

    $vss = $_

    $vss.Uplinks | where{$_ -ne $null} | %{

    $nic = $_

    $netAdapt = Get-VMHostNetworkAdapter -VMHost $esxcli.VMHost -Name $nic

    $nicList = $esxcli.network.nic.list.Invoke() | where{$_.Name -eq $nic}

    $esxcli.network.nic.get.Invoke(@{nicname="$_"}) |

    Select @{N='VMHost';E={$esx.Name}},

    @{N='ConfiguredSpeed';E={
    if ($_.ExtensionData.AutoNegotiateSupported)
    {'Auto negotiate'} else {$_.ExtensionData.Spec.LinkSpeed.SpeedMb}}},



  • 4.  RE: List configured Speed of Physical adapter of ESXi

    Posted Jan 05, 2022 10:57 AM

    If I guess correctly, there is a Get-VMHost before.
    You are using the objects produced by the esxcli command, while you should be using the $netAdapt variable (I think)

    Get-VMHost -PipelineVariable esx |
    ForEach-Object -Process {
      $esxcli = Get-EsxCli -VMHost $esx -V2
      $esxcli.network.vswitch.standard.list.Invoke() |
      ForEach-Object -Process {
        $vss = $_
        $vss.Uplinks | Where-Object { $_ -ne $null } | ForEach-Object {
          $nic = $_
          $netAdapt = Get-VMHostNetworkAdapter -VMHost $esxcli.VMHost -Name $nic
          $nicList = $esxcli.network.nic.list.Invoke() | Where-Object { $_.Name -eq $nic }
          $esxcli.network.nic.get.Invoke(@{nicname = "$_" }) |
          Select-Object @{N = 'VMHost'; E = { $esx.Name } },
          @{N = 'ConfiguredSpeed'; E = {
              if ($netAdapt.ExtensionData.AutoNegotiateSupported)
              { 'Auto negotiate' } else { $netAdapt.ExtensionData.Spec.LinkSpeed.SpeedMb } }
          }
        }
      }
    }

     



  • 5.  RE: List configured Speed of Physical adapter of ESXi

    Posted Jan 05, 2022 11:10 AM

    Hello Luc,

    It's perfect now the data is generated for configured speed.

    thanks a lot for your help.

     

    regards

    David