PowerCLI

 View Only
  • 1.  Find VLAN Name from VLAN ID

    Posted Dec 19, 2019 03:32 PM

    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.



  • 2.  RE: Find VLAN Name from VLAN ID

    Posted Dec 19, 2019 03:39 PM

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

    256 is the VLAN ID



  • 3.  RE: Find VLAN Name from VLAN ID

    Posted Dec 19, 2019 04:02 PM

    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?



  • 4.  RE: Find VLAN Name from VLAN ID

    Posted Dec 19, 2019 05:20 PM

    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



  • 5.  RE: Find VLAN Name from VLAN ID

    Posted Dec 19, 2019 06:43 PM



  • 6.  RE: Find VLAN Name from VLAN ID

    Posted Dec 19, 2019 06:53 PM

    Ah youre running an older version, im on:

    PowerCLI Version

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

       VMware PowerCLI 11.5.0 build 14912921

    try

    get-vdportgroup | select Name, VlanConfiguration



  • 7.  RE: Find VLAN Name from VLAN ID

    Posted Dec 19, 2019 06:59 PM

    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:



  • 8.  RE: Find VLAN Name from VLAN ID

    Posted Dec 19, 2019 07:07 PM

    upgrade your powercli, works ok for me...



  • 9.  RE: Find VLAN Name from VLAN ID

    Posted Dec 19, 2019 09:17 PM

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



  • 10.  RE: Find VLAN Name from VLAN ID

    Posted Dec 20, 2019 08:58 AM

    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.