After I wrote the licensing server post a couple of days back one of my colleagues(Thanks Horst!) was so kind to email me the following script. What it basically does is check every server for the availability of the license source. Of course it can be improved by adding for instance a check to see if the license service is running on the license server and for instance email the results if there’s an error…I will leave that up to the powershell guru’s like mr Renouf. Here’s the script:

# This script checks the availability of the configured license source for all ESX hosts that are managed by a given VC
# The script assumes that there is a user account that has the same password on all hosts
# It is higly recommended to use an account that has a read-only role
# The first credential pop-up is for VC, the second for ESX hosts
connect-viserver <VC>
$vmhosts = Get-VMHost
Disconnect-VIServer -Confirm:$false
$numhosts = $vmhosts.Length
if ($numhosts -eq 0) { exit 1 }
$credential = Get-Credential
$availability = @{}
$badcounter = 0;
$hostcounter = 1
$vmhosts | foreach {
$progress = [int] ($hostcounter * 100 / $numhosts)
Write-Progress “Checking license source availability” “Checking Host” -PercentComplete $progress -CurrentOperation “Checking host $_”
connect-VIServer $_.name -Credential $credential
$svcRef = new-object VMware.Vim.ManagedObjectReference;
$svcRef.Type = “ServiceInstance”;
$svcRef.Value = “ServiceInstance”;
$serviceInstance = get-view $svcRef;
$lic_ref = $serviceInstance.content.licensemanager;
$LM = Get-View $lic_ref;
$available = $LM.SourceAvailable
$availability[$_.Name] = $available
if ($available -eq $false ) { $badcounter++ }
Disconnect-VIServer -Confirm:$false
$hostcounter++
}
Write-Host $badcounter ” Hosts without available license source.”
foreach ($item in $availability.GetEnumerator() )
{
if ($item.value -eq $False ) {Write-Host “Host ” $item.name ” does not have a valid license source” }
}