Licensing in a virtualized world...Somewhat of a pain

Not only do you have to manage your vmware licenses, you have to make sure the VM's you are running are properly covered under an associated OS license.  I haven't really seen an elegant solution to this type of conundrum.  So I needed to create a script to look @ all my ESX hosts and see how many physical sockets they have and to see if there were Windows VM's running on them.

This way I could true up which ESX hosts I needed to license Windows Datacenter processor licenses against.  The same type logic could be applied for RHEL licenses.  Anyway, without further ado, here is the snippet I wrote up:

$vmhosts = Get-vmhost

$LicenseData = @()
Foreach ($vmhost in $vmhosts)
{
$NewDataSet = "" | Select Name, NumSockets,Cluster, Windows
$NewDataSet.name = $vmhost.name
$NewDataSet.numSockets = $vmhost.extensiondata.hardware.cpuinfo.numcpupackages
$NewDataSet.Cluster = $vmhost.parent.name
$NewDataSet.Windows = If (($vmhost | Get-VM | where {$_.guest -match "Windows"}).count -gt 0){"Yes"}Else{"No"}
$LicenseData += $NewDataSet
}

This'll return data in this type format:
Name of ESX host
Number of physical sockets
Cluster or parent node name
If a windows vm is found yes is returned, otherwise no.

Testing Port Connectivity from an ESXi host

Summary:
I'm so used to testing connectivity to an ESXi server from a windows or Linux system, that I never thought about how to do it the other way around.  It took me a bit to find it so I figure I should post on this for my reference @ a later date.

The key command from the CLI:
nc (aka netcat)

nc -z DestinationIP DestinationPort -v

Example:
In my case, I was trying to get Emulex onecommand to download and install firmware to my HBA's.  Emulex onecommand was running on my tools server on ports 8080 and 8443.  To test my connection, I passed the following command:
nc -z myToolsServerIP 8080 -v
and
nc -z myToolsServerIP 8443 -v

The commands would just hang, meaning the ports were not responding.  A quick e-mail to my firewall teams and they were able to fix the problem by opening up the ports.

VMware KB: 2020669
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2020669