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
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}}
Something like this?
$VLANID = 1234
Get-VDPortgroup | ?{$_.VlanConfiguration.VLANID -eq $VLANID}
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}
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}}