VMware Cloud Community
RajuVCP
Hot Shot
Hot Shot

Script to get DVportgroup or Standardswtich portgroup Name, Vlan id, total ports and available ports

Hi All,

Is there any script which can give both Standardswitch and Distributed Switch Portgroup Vlan name, Vlan id, total ports and available ports.

we have numerous vlan manuall efforts to check the same will be totally time consuming. if any one have such script will be most helpfull for me.

Thanks a ton in advance.

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos
5 Replies
LucD
Leadership
Leadership

Have a look at Listing vswitch info


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

0 Kudos
RajuVCP
Hot Shot
Hot Shot

Thanks LucD for your fast response as always. . Smiley Happy

above given link gives details of portgroup vlan tagged details.

I was mostly looking for no of available ports, total port in a portgroup. :smileyconfused:

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos
LucD
Leadership
Leadership

I know, but does this work for you.

The ports can be added if I'm sure it's working


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

0 Kudos
RajuVCP
Hot Shot
Hot Shot

Thanks LucD for reply...:)

Am looking for Portgroup ports availability data., total ports data.. whats happening in my environment.. portgroup A with 250 ports and portgroup B with 250 ports.

Portgroup A filled with more than 250 VMs , which the remaining Vms not able to acquire IPs,

Where in Portgroup B with 250 Ports having 100-150 VMs only still have many ports available for VMs to get an IP.

Just want to have data it across VC of totalports and available ports in portgroup.

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos
LucD
Leadership
Leadership

Try the following, but I'm not sure what you want to see for portgroups on a VSS.

There the number of ports is on the switch level, not the portgroup level afaik.

Get-VirtualPortGroup |

Select Name,

    @{N='Host';E={

        if($_ -is [VMware.VimAutomation.ViCore.Impl.V1.Host.Networking.DistributedPortGroupImpl]){

            [string]::Join(',',(Get-View -Id $_.ExtensionData.Host -Property Name | %{$_.Name}))

        }

        else{

            Get-View -Id $_.VMHostId | Select -ExpandProperty Name

        }}},

    @{N='Type';E={

        if($_ -is [VMware.VimAutomation.ViCore.Impl.V1.Host.Networking.DistributedPortGroupImpl]){

            'VDS'

        }

        else{'VSS'}}},

    @{N='VlanId';E={

        if($_ -is [VMware.VimAutomation.ViCore.Impl.V1.Host.Networking.DistributedPortGroupImpl]){

            if($_.ExtensionData.Config.DefaultPortConfig.Vlan -is [VMware.Vim.VmwareDistributedVirtualSwitchPvlanSpec]){

                $_.ExtensionData.Config.DefaultPortConfig.Vlan.PvlanId

            }

            elseif($_.ExtensionData.Config.DefaultPortConfig.Vlan -is [VMware.Vim.VmwareDistributedVirtualSwitchVlanSpec]){

                if($_.ExtensionData.Config.DefaultPortConfig.Vlan.VlanId -is [VMware.Vim.NumericRange[]]){

                    [string]::Join(',',($_.ExtensionData.Config.DefaultPortConfig.Vlan.VlanId | %{"$($_.Start)-$($_.End)"}))

                }

                else{

                    $_.ExtensionData.Config.DefaultPortConfig.Vlan.VlanId

                }

            }

        }

        else{$_.VlanId}}},

    @{N='Available ports';E={

        if($_ -is [VMware.VimAutomation.ViCore.Impl.V1.Host.Networking.DistributedPortGroupImpl]){

            $_.numPorts - $_.ExtensionData.Vm.Count

        }

        else{'na'}}},

    @{N='Total ports';E={

        if($_ -is [VMware.VimAutomation.ViCore.Impl.V1.Host.Networking.DistributedPortGroupImpl]){

            $_.NumPorts

        }

        else{'na'}}}


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

0 Kudos