Automation

 View Only
  • 1.  Get portgroup name through vlan id

    Posted Aug 19, 2015 09:14 AM

    Hi,

    i have several vlan id's. Therefore i want to get the portgroup names, where the vlan id is configured. We use dv-Switches, so i don't want to ask the the vmhost.

    Kind regards

    Bergold



  • 2.  RE: Get portgroup name through vlan id

    Posted Aug 19, 2015 09:26 AM

    Something like this?

    $VLANID = 1234

    Get-VDPortgroup | ?{$_.VlanConfiguration.VLANID -eq $VLANID}



  • 3.  RE: Get portgroup name through vlan id

    Posted Aug 19, 2015 09:50 AM

    Hi Oskar,

    thx for this answer. Is there a way to do the same with private-vlans?

    I tried:

    $VLANID = 1234

    Get-VDPortgroup | ?{$_.VlanConfiguration.PVLANID -eq $VLANID}



  • 4.  RE: Get portgroup name through vlan id
    Best Answer

    Posted Aug 19, 2015 10:31 AM

    Sure, but since they have both a Primary and a Secondary VLAN, they are a bit different.

    If it is the Primary VLAN you are after, then you can use:

    Get-VDPortgroup | where{$_.VlanConfiguration.PrimaryVlanId -eq $VLANID}


    If it is the Secondary VLAN you are after, then you can use:

    Get-VDPortgroup | where{$_.VlanConfiguration.SecondaryVlanId -eq $VLANID}


    So if you want to find all VLANs with ID $VLANID no matter which, you can combine them:

    Get-VDPortgroup | where{$_.VlanConfiguration.VlanId -eq $VLANID -or $_.VlanConfiguration.PrimaryVlanId -eq $VLANID -or $_.VlanConfiguration.SecondaryVlanId -eq $VLANID}


    If you want to find all PVLANs you can use:

    Get-VDPortgroup | where{$_.VlanConfiguration.VlanType -eq "PrivateVLAN"}


    Note that you also have the option "VLAN Trunking" in the GUI which can be a range of VLANs. You can find these by:

    Get-VDPortgroup | where{$_.VlanConfiguration.VlanType -eq "Trunk"} | Select Name, @{N="Ranges";E={$_.VlanConfiguration.Ranges}}