Check HP Management Agents with PowerCLI
Checking on the existence of HP Management Agents on your ESX hosts and/or their version is rather easy with PowerCLI.
Connect to your vCenter hosts using the Connect-VIServer cmdlet (remember that you can connect to multiple servers!).
Run the following piece of code to check to HP Agents:
$ESXHosts = Get-View -ViewType "HostSystem" -Property Name, Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo
[PSObject[]] $objOutput = @()
Foreach ($ESXHost in $ESXHosts)
{
$lobjHPAgent = $ESXHost.Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | Where-Object {$_.Name -like "*hp-agents-config*"}
If ($lobjHPAgent -ne $null)
{
$lstrHPAgentVersion = $lobjHPAgent.Name.SubString($lobjHPAgent.Name.IndexOf(" ", 1) + 1)
$lstrHPAgentVersion = $lstrHPAgentVersion.SubString(0, $lstrHPAgentVersion.IndexOf("@"))
}
Else
{
$lstrHPAgentVersion = "Not Installed"
}
$objESX = New-Object PSObject -Property @{Name = $ESXHost.Name;Version = $lstrHPAgentVersion}
$objOutput += $objESX
}
$objOutput
This gives you a nice output like this:
The code might not be the shortest one, but it’s fast and gives you an Object that you can pipe through Sort-Object, Format-Table, …
Looks like this is only working with ESX4.1 Previous ESX versions show Not Installed.
A great script when 4.1 is rolled out.
Strange. The properties are available in ESX 4.0 so it should be possible to read them out. I tested on ESX 4.1 only since i didn’t have a ESX 4.0 available at that time.
In ESX 4.1, the Agents have “hp-agents-config” in their name, they might go under another name in ESX 4.0.
I suggest you output $ESXHost.Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo where $ESXHost is the result of “Get-View -ViewType HostSystem -Filter @{“Name”=””}. Look for anything with *hp* in it.
Let me know if you find anything so i can change the script.
Please let me know will this run on ESX3.5. Need some script to find the HP management agent version on ESX 3.5
I just verified this and ESX 3.5 doesn’t expose this info through the SDK…