Automation

 View Only
  • 1.  phisical nic _vlan_info_powercli

    Posted Nov 17, 2017 12:10 PM

    Hello Luc/all,

    i have one standard switch info stored in variable in $s

    if i do $s.nic it gave me me two physical nic

    can yu please tell me how to get what vlans are allowed on these physical nics using powercli.



  • 2.  RE: phisical nic _vlan_info_powercli

    Posted Nov 17, 2017 12:13 PM

    Do you mean "allowed" or "defined"?

    For allowed one would have to query the physical switch via CDP (or similar).

    For defined, one would need to look at all the portgroups defined on those pnics.



  • 3.  RE: phisical nic _vlan_info_powercli

    Posted Nov 17, 2017 12:24 PM

    allowed.

    actually i moved one of the esxi hostfrom one vcenter to another .

    instead of importing that distributed switch im creating required port groups on standrd switch (though not good practice but tesst environamet)

    right now webclient not working so thought of checking all allowed on those phy nic.(using powercli)

    there is way to check through esxcli (by ssh to esxi)

    i want to use below using powercli.

    Network Troubleshooting Using ESXCLI 5.1 - VMware vSphere Blog



  • 4.  RE: phisical nic _vlan_info_powercli

    Posted Nov 17, 2017 12:43 PM

    You can do something like this

    $esxName = 'MyEsx'

    $vssName = 'MySwitch'

    $esx = Get-VMHost -Name $esxName

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

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

    where{$_.VirtualSwitch -eq $vssName} |

    Select Name,VLANID



  • 5.  RE: phisical nic _vlan_info_powercli

    Posted Nov 17, 2017 01:09 PM

    Thanks Luc,

    but very specifically i want to enable vlan stats and to get allowed vlan info  on both physical nic connected to vss.

    so i tried

    following  how to use these methods do i need to put .invoke() or what is the correct syntax .

    esxi shell equvalent are

    esxcli network nic vlan stats set -e true -n vmnic2

    and then run the following command to retrieve all VLAN stats for that given vmnic interface (replace with the vmnic of choice):

    esxcli network nic vlan stats get -n vmnic2



  • 6.  RE: phisical nic _vlan_info_powercli
    Best Answer

    Posted Nov 17, 2017 01:43 PM

    Try like this.

    You can eventually run the last part ('Retrieve stats') in a loop on an interval.

    $esxName = 'MyEsx'

    $vssName = 'MySwitch'

    $esx = Get-VMHost -Name $esxName

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

    $vss = $esxcli.network.vswitch.standard.list.Invoke() | where{$_.Name -eq $vssName}

    # Activate stats

    $vss.Uplinks | %{

        $sStat = @{

            nicname = $_

            enabled = $true

        }

        $esxcli.network.nic.vlan.stats.set.Invoke($sStat)

    }

    # Retrieve stats

    foreach($pnic in $vss.Uplinks){

        $gStat = @{

            nicname = $pnic

        }

        $esxcli.network.nic.vlan.stats.get.Invoke($gStat) | Select -Property @{N='pNIC';E={$pnic}},*

    }



  • 7.  RE: phisical nic _vlan_info_powercli

    Posted Nov 17, 2017 02:38 PM

    Thanks Luc. it worked fine.

    i find a series of vlans per vmnic .

    that means all these vlans are allowed(not sure what you mean by defined earlier) and this vmnic is connected to trunk port of the physical switch . is this correct?



  • 8.  RE: phisical nic _vlan_info_powercli

    Posted Nov 17, 2017 02:41 PM

    With "defined" I mean what is defined on the trunk on the physical switch.

    When CDP is enabled, you can query the switch.

    Yes, your assumption is correct.



  • 9.  RE: phisical nic _vlan_info_powercli

    Posted Nov 17, 2017 05:21 PM

    cdp is enabled but by query the switch you mean by using powercli or through webclient .

    also is there any way i can get what is configured inside guest os (like ip,defaultgatewat,dns)

    i was able to find ip address by using $vm.guest.....nested property but not other info.



  • 10.  RE: phisical nic _vlan_info_powercli

    Posted Nov 17, 2017 05:25 PM

    The network settings inside the guest OS are not all available through PowerCLI directly.

    You will have to query inside the guest OS, for example through Invoke-VMScript.

    You can query CDP info through PowerCLI.

    Have a look at Jonathan's post Obtaining CDP info via PowerCLI



  • 11.  RE: phisical nic _vlan_info_powercli

    Posted Nov 17, 2017 05:36 PM

    thnaks iam checking it.