VMware Cloud Community
Bergold
Enthusiast
Enthusiast
Jump to solution

Get portgroup name through vlan id

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

0 Kudos
1 Solution

Accepted Solutions
LittleNickey
Enthusiast
Enthusiast
Jump to solution

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

-- Oskar

View solution in original post

0 Kudos
3 Replies
LittleNickey
Enthusiast
Enthusiast
Jump to solution

Something like this?

$VLANID = 1234

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

-- Oskar
0 Kudos
Bergold
Enthusiast
Enthusiast
Jump to solution

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}

0 Kudos
LittleNickey
Enthusiast
Enthusiast
Jump to solution

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

-- Oskar
0 Kudos