www.vmwareadmins.com

how many VMs can you put in a box?

  • Increase font size
  • Default font size
  • Decrease font size
Home Articles Finding what portgroups are on each cluster

Finding what portgroups are on each cluster

E-mail Print PDF

So in my environment, we have 70+ hosts with a glob of VM's running on top of those 70+ hosts... which at times can make things a configuration nightmare. Our super intelligent networking/security team decided prior to my employment here that they were going to use as many VLAN's as possible. So in turn, I'll have as many portgroups as possible for said VLAN's :)

So I pulled out the trusty vSphere  PowerCLI and started plugging away... here's what I came up with.

$myCol = @()
ForEach ($VMHost in (Get-VMHost | Sort Name))
    {
    ForEach ($VM in ($VMHost | Get-VM))
        {
        ForEach ($NIC in (Get-NetworkAdapter -VM $VM))
            {
            $myObj = "" | Select VMHost, VM, NIC, PortGroup, vSwitch
            $myObj.VMHost = $VMHost.Name
            $myObj.VM = $VM.Name
            $myObj.NIC = $NIC.Name
            $myObj.PortGroup = Get-VirtualPortGroup -VM $VM -Name $NIC.NetworkName
            $myObj.vSwitch = $myObj.PortGroup.VirtualSwitchName
            $myCol += $myObj
            }
        }
    }
$myCol | Group-Object VMHost, vSwitch -NoElement | Sort Name | Select Name, Count

 

 

 

 

Follow Me On...

Facebook linkedin twitter youtube