Nothing too fancy here, just a quick and dirty way to find the current counts of all of my ESXi 4.1 (Build 260247) versus the remaining ESX hosts.
This really comes in handy when measuring the progress of upgrading from ESX 4.0 to ESXi 4.1.
[powershell]
$viserver = Connect-VIServer vcenter.domain.com -Protocol https
$vmhosts = Get-VMHost
$details = @()
$esx = 0
$esxi = 0
foreach ($vmhost in $vmhosts){
$detail = ""|select HostName,Version
$detail.Hostname = $vmhost.Name
$detail.Version = $vmhost.ExtensionData.Config.Product.FullName
$details += $detail
if ($detail.Version -like "*260247") {
$esxi = $esxi + 1
} else {
$esx = $esx+1
}
}
Write-Output "ESX: " $esx
Write-Output "ESXi: " $esxi
[/powershell]