Automation

 View Only
  • 1.  VLanID using Get-VirtualPortGroup

    Posted Oct 23, 2023 04:48 PM

    Trying to retireve Vlan Ids of my VIrturalPortgroups using powercli.  I can see the VLanIds clearly in the GUI; however, if using Get-VirtualPortGroup command in powercli, it retrieves all other Info, however, VlanID is blank.  



  • 2.  RE: VLanID using Get-VirtualPortGroup
    Best Answer

    Posted Oct 23, 2023 05:12 PM

    If you are working with VSS, not VDS, you could do

    Get-VirtualPortGroup -Standard |
    Select-Object Name,
        @{N='VLAN';E={$_.ExtensionData.Config.DefaultPortConfig.Vlan.VlanId}}
    

    If you also want to report on VDS have a look at Solved: Re: List Portgroups with Private VLANS - VMware Technology Network VMTN

     



  • 3.  RE: VLanID using Get-VirtualPortGroup

    Posted Oct 23, 2023 06:26 PM

    Thanks so much.  These were all going to be VDI so used your link .  Worked like a champ

    #Get portgroup
        $nadapter = Get-NetworkAdapter -vm $imageName
        $vPGName = $nadapter.NetworkName
        $vPortGroup = Get-VirtualPortGroup | Where-Object { $_.Name -eq $vPGName }
        $vlanId = $vPortGroup.ExtensionData.Config.DefaultPortConfig.Vlan.VlanId