VMware Cloud Community
pamiller21
Enthusiast
Enthusiast
Jump to solution

Portgroup/VLAN Tag Report

Hey all,

I am looking for a report to show all portgroups and what VLAN Tags they are using.  Just want to use this for quick comparison and verification that everything is working.  We currently use for vSSs and vDSs, so it would be great if for the vSSs to show the vHost that they reside on.  Let me know if this is an achievable goal or just a dream.


Thanks all,Andy

Reply
0 Kudos
1 Solution

Accepted Solutions
jterli
VMware Employee
VMware Employee
Jump to solution

You can try the below script for the port groups report :

Connect-VIServer -Server 'server' -User 'user' -Password 'passwd'

$Report = @()

foreach ($spg in (Get-VirtualPortGroup -Standard))

       {

         $row = "" | Select Name,VLanId

         $row.Name = $spg.Name

         $row.VLanId = $spg.VLanId

         $Report += $row

      }

foreach ($dpg in Get-VDPortgroup)

      {

        $row = "" | Select Name,VLanId

        $row.Name = $dpg.Name

        if($dpg.Extensiondata.Config.DefaultPortCOnfig.Vlan.VlanId -match '\d')

         {

           $row.VLanId = $dpg.Extensiondata.Config.DefaultPortCOnfig.Vlan.VlanId

         }

        else

         {

            $start = $dpg.Extensiondata.Config.DefaultPortCOnfig.Vlan.VlanId.Start

            $end = $dpg.Extensiondata.Config.DefaultPortCOnfig.Vlan.VlanId.End

            $row.VLanId = "$start" + ' - ' + "$end"

          }

        $Report += $row

        }


$Report | Export-Csv "test.csv"

The ask related to vSSs hostname is not clear to me.

If you just need the vSS to hostname mapping then you can use the below :

Get-VirtualSwitch -Standard | select Name, @{N="HostName";E={$_.VMHost.Name}}

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Have a look at 2.  Re: List Portgroups with Private VLANS

I think it shows all the info you are looking for.


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

Reply
0 Kudos
jterli
VMware Employee
VMware Employee
Jump to solution

You can try the below script for the port groups report :

Connect-VIServer -Server 'server' -User 'user' -Password 'passwd'

$Report = @()

foreach ($spg in (Get-VirtualPortGroup -Standard))

       {

         $row = "" | Select Name,VLanId

         $row.Name = $spg.Name

         $row.VLanId = $spg.VLanId

         $Report += $row

      }

foreach ($dpg in Get-VDPortgroup)

      {

        $row = "" | Select Name,VLanId

        $row.Name = $dpg.Name

        if($dpg.Extensiondata.Config.DefaultPortCOnfig.Vlan.VlanId -match '\d')

         {

           $row.VLanId = $dpg.Extensiondata.Config.DefaultPortCOnfig.Vlan.VlanId

         }

        else

         {

            $start = $dpg.Extensiondata.Config.DefaultPortCOnfig.Vlan.VlanId.Start

            $end = $dpg.Extensiondata.Config.DefaultPortCOnfig.Vlan.VlanId.End

            $row.VLanId = "$start" + ' - ' + "$end"

          }

        $Report += $row

        }


$Report | Export-Csv "test.csv"

The ask related to vSSs hostname is not clear to me.

If you just need the vSS to hostname mapping then you can use the below :

Get-VirtualSwitch -Standard | select Name, @{N="HostName";E={$_.VMHost.Name}}

Reply
0 Kudos
pamiller21
Enthusiast
Enthusiast
Jump to solution

Sorry for the leaving this post high and dry, but I finally got back to this and tested.  This is very close to what I am looking for is just like you have except, when it comes to the VSS portgroups your script has the VSS portgroup in column 1 and the VLAN tag in column 2, but I also need the vHost that the VSS is on so I can hunt down if I have a VLAN tag incorrectly configured.  The rest of what you have is perfect.

Thank you for any help,
Andy

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The thread I linked to earlier does contain the ESXi node name


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

Reply
0 Kudos