Home > PowerCLI, vSphere > Check HP Management Agents with PowerCLI

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:

image

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, …

Categories: PowerCLI, vSphere
  1. January 17, 2011 at 16:16

    Looks like this is only working with ESX4.1 Previous ESX versions show Not Installed.
    A great script when 4.1 is rolled out.

    • January 17, 2011 at 19:21

      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.

  2. sadmin
    March 10, 2011 at 15:41

    Please let me know will this run on ESX3.5. Need some script to find the HP management agent version on ESX 3.5

    • March 16, 2011 at 11:05

      I just verified this and ESX 3.5 doesn’t expose this info through the SDK…

  1. No trackbacks yet.

Leave a comment