VMware Cloud Community
jpool1
Contributor
Contributor

Find VLAN Name from VLAN ID

How would I find a vlan name from a vlan ID in PowerCLI? I have done a lot of searching online but have not been able to find anything. Basically I have a list of vlan ids but they have the wrong names and I need to iterate through them and make a new sheet with the right names.

Tags (1)
Reply
0 Kudos
9 Replies
T180985
Expert
Expert

get-virtualportgroup  | Where {$_.VLanId -eq "256"}

256 is the VLAN ID

Please mark helpful or correct if my answer resolved your issue. How to post effectively on VMTN https://communities.vmware.com/people/daphnissov/blog/2018/12/05/how-to-ask-for-help-on-tech-forums
Reply
0 Kudos
jpool1
Contributor
Contributor

When I ran that command, I got a "Get-VirtualPortGroup  Object reference not set to an instance of an object" error.

I also got the following output:

"WARNING: The output of the command produced distributed virtual portgroup objects. This behavior is obsolete and may change in the future. To retrieve distributed portgroups, use Get-VDPortgroup cmdlet in the VDS component. To retrieve standard portgroups, use -Standard."

Do you guys have any idea what this means?

Reply
0 Kudos
T180985
Expert
Expert

just tested and it definitely works for me... can you run Get-PowerCLIVersion and let us know the version you're running? attach a screenshot of your error

Please mark helpful or correct if my answer resolved your issue. How to post effectively on VMTN https://communities.vmware.com/people/daphnissov/blog/2018/12/05/how-to-ask-for-help-on-tech-forums
Reply
0 Kudos
jpool1
Contributor
Contributor

pastedImage_1.png

pastedImage_2.png

Reply
0 Kudos
T180985
Expert
Expert

Ah youre running an older version, im on:

PowerCLI Version

----------------

   VMware PowerCLI 11.5.0 build 14912921

try

get-vdportgroup | select Name, VlanConfiguration

Please mark helpful or correct if my answer resolved your issue. How to post effectively on VMTN https://communities.vmware.com/people/daphnissov/blog/2018/12/05/how-to-ask-for-help-on-tech-forums
Reply
0 Kudos
jpool1
Contributor
Contributor

Well that command works, but it doesn't get me the name based on a vlan id. I also tried the following, but no luck:

pastedImage_0.png

Reply
0 Kudos
T180985
Expert
Expert

upgrade your powercli, works ok for me...

pastedImage_0.png

Please mark helpful or correct if my answer resolved your issue. How to post effectively on VMTN https://communities.vmware.com/people/daphnissov/blog/2018/12/05/how-to-ask-for-help-on-tech-forums
Reply
0 Kudos
jpool1
Contributor
Contributor

Thanks for your help Tony, I'm currently working on getting an upgrade.

Reply
0 Kudos
LucD
Leadership
Leadership

While I definitely encourage you to upgrade your PowerCLI version, that is not the real issue at hand.
The Get-VirtualGroup cmdlet has been marked "deprecated" since quite some time.

The real issue is that the VlanIds for a VSS and a VDS are not obtained in the same way.

Have a look for example at Re: List Portgroups with Private VLANS
You could eventually use that script, and pipe the result to a Where-clause that filters on the VlanId property.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos