Wednesday 28 July 2010

Changing the ESX license server

I had to change and reset the license server on a number of hosts, and thanks to the brilliant Hugo Peeters, and some assistance from one of our scripting guru's here at work, I knocked up some Powershell to reach out to a cluster and check the status of it's license server. If the service is stopped, or not responding the correct server, it is corrected and restarted. It's also nicely wrapped into a function :)




Function Set-ESXLicenseHost


{


$ESXHosts = get-vmhost


ForEach ($VMHost in $ESXHosts)


{


$SI = Get-View ServiceInstance


$LM = Get-View $SI.Content.LicenseManager


$VMHostView = Get-VMHost $VMHost


Get-View


$VMHostRef = $VMHostView.MoRef


$LicUse = $LM.QueryLicenseUsage($VMHostRef)


$VMHost.Name


If ($LicUse.sourceAvailable -ne 'True')


{


write-output "Not Available - resetting service"


$hostref = ($VMHost


Get-View).MoRef


$LicServer = “INT01VCC01”


$licsrc = New-Object VMware.Vim.LicenseServerSource


$licsrc.LicenseServer = $LicServer


$LicMan.ConfigureLicenseSource($hostref,$licsrc)


}


else


{


write-output "Available"


}


}


}

0 comments:

Post a Comment