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.
get-virtualportgroup | Where {$_.VLanId -eq "256"}
256 is the VLAN ID
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?
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
Ah youre running an older version, im on:
PowerCLI Version
----------------
VMware PowerCLI 11.5.0 build 14912921
try
get-vdportgroup | select Name, VlanConfiguration
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:
upgrade your powercli, works ok for me...
Thanks for your help Tony, I'm currently working on getting an upgrade.
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
