Create a vSwitch Port Overview with Powershell

WARNING: VMware vmotion does not check wether there are sufficient ports available on the virtual switch on the destination host. Migrating a vm to a host with insufficient ports will cause the vmotion to complete without warnings, yet the virtual NIC will be disconnected! This issue is descripbed in this KB article.
The solution to this problem is to create vSwitches with sufficient ports, obviously. Do you want to know how many ports are currently being used on every vSwitch in your environment? vSphere PowerCLI to the rescue! Try the following script:

$VC = Connect-VIServer "MyVCServer"
$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
Disconnect-VIServer -Confirm:$false
For now, we have to go out there and play the way that he motivates us, and the way he leads us to play. Yesterday, all of America watched as Commissioner Adam Silver and the NBA acted justly in punishing Donald Sterling for his hateful, racist behavior. Michael Sam has been cheap ray bans placed on the Montreal Alouettes’ suspended listafter leaving the Canadian Football League team for unspecified personal reasons last week. This contretemps is a fitting kickoff to the two worst weeks of football media coverage of the season. “I decided that the strongest measure was best for the Review Journal. Perhaps watching a movie at a theatre during a matinee showtime would be a better fit for some introvert people. The on demand games will have additional camera angles as well.. Have extra adults at the party available to help. The weekend benefits the Salvation Army of Greater http://www.cheapnfljerseyssu.com Philadelphia, Grab a Ball an organization that gives athletic balls to underprivileged children started by Erving’s daughter Jazmin, and DEFY, a charity established by Dorys Erving that provides healthy meals and nutrition training to overweight children. To clarify, I support Colin motivation. This will be the only time we will comment on this unfounded and ridiculous claim.’. In the months leading up to the rematch, NFL Jerseys China they had a difficult time securing a venue, partially due to rumors of mob involvement, which is how they ended up in Maine. Tom thanks so much for being with us.. Subscribe to USA TODAYAlready a print edition subscriber, but don’t have a login?Activate your Wholesale Jerseys digital access.Manage your account settings.My AccountLog OutCheck back here throughout the day for all the latest quick hit news:Gruden staying put?If you believe Jon Gruden, he’s not in the mix to be the next coach of the Los Angeles Rams (or Jacksonville Jaguars).”I’m very happy http://www.cheapnfljerseysx.com doing what I’m doing,” Gruden said Wednesday morning on ESPN Radio’s Mike and Mike in the Morning.”My full attention and focus is on Cowboys Lions, I cannot wait for our final Monday night game. I mean, do you feel like you offered enough in this book? You know, could you have brought up some of those details and really explained in your mind why.. Ryan teams finished 4 9 against the Patriots.. Total videogame sales tumbled in November, led again by a slip in console hardware, though the industry saw declines in every area, and titles faced a tough comp from last November. 5, 1989. And because “Budai” and “Buddha” sound alike, over time ordinary folks made the mistake of confusing the constantly smiling fat guy for the http://cheapjerseysupply.com symbol of Buddhism, the belief system cheap jordan that teaches that happiness brings you closer to enlightenment..

2 thoughts on “Create a vSwitch Port Overview with Powershell”

  1. something like this:

    $mycol = @()
    foreach ($vmhost in (get-vmhost | sort name))
    {
    foreach ($ports in ($vmhost | Get-VirtualSwitch | where {$_.name -eq “vSwitch2”}))
    {
    $myobj = “” | select VMhost, Ports, VMcount, Available
    $myobj.vmhost = $vmhost.name
    $myobj.vmcount = ($vmhost | get-vm | get-networkadapter).count
    $myobj.ports = $ports.numports
    $myobj.available = ($ports.numports – ($vmhost | get-vm | get-networkadapter).count)
    $mycol += $myobj
    }}
    $mycol

Leave a Reply