Setup: A HP server with Windows OS and WMI enabled. Latest WBEM drivers installed.

Problem: You want to query server details regarding the Storage Array Controller and disks installed.

Solution: Run this PowerShell script from a remote computer.

# The script takes the name of the remote computer as parameter
      [string] $strComputer
# ask for credentials to connect to remote computer. Credentials can be stored on the disk for unattended execution.
$cred = get-credential

$cd = "" | select Name
Add-Member -memberType NoteProperty -name RaidController -inputObject $cd -value "N/A"
Add-Member -memberType NoteProperty -name HDD_Raid_Configuration -inputObject $cd -value "N/A"
Add-Member -memberType NoteProperty -name HDD_Configuration -inputObject $cd -value "N/A"
Add-Member -memberType NoteProperty -name No_HDD_Bays_Used -inputObject $cd -value 0
Add-Member -memberType NoteProperty -name No_HDD_Bays -inputObject $cd -value 0

$ = $strComputer
# Disk array subsystem
$StorageVolume = Get-WmiObject -class HPSA_StorageVolume -computername $strComputer -namespace "root\HPQ" -ErrorAction SilentlyContinue -credential $cred
$ArrayController = Get-WmiObject -class HPSA_ArrayController -computername $strComputer -namespace "root\HPQ" -ErrorAction SilentlyContinue -credential $cred| select ElementName
$cd.RaidController = $ArrayController.ElementName
$DiskDrive = Get-WmiObject -class HPSA_DiskDrive -computername $strComputer -namespace "root\HPQ" -ErrorAction SilentlyContinue -credential $cred
$StorageVolume = Get-WmiObject -class HPSA_StorageVolume -computername $strComputer -namespace "root\HPQ" -ErrorAction SilentlyContinue -credential $cred| select elementname,deviceid
$RaidDisks = @()
Get-WmiObject -class HPSA_StorageExtentStorageVolume -computername $strComputer -namespace "root\HPQ" -ErrorAction SilentlyContinue -credential $cred| %{$rd = ""| select raid,disk;$rd.disk=$_.antecedent.split(",")[1].split("=")[1].trimstart('"').trimend('"');$$_.dependent.split(",")[1].split("=")[1].trimstart('"').trimend('"');$RaidDisks += $rd}
[email protected]{}
Get-WmiObject -class HPSA_DiskPhysicalPackage -computername $strComputer -namespace "root\HPQ" -ErrorAction SilentlyContinue -credential $cred| select name,model,serialnumber,tag |  %{$dsk = "" | select bay,model,sn,tag;$dsk.bay=$[2];$dsk.model=$_.model;$ = $_.serialnumber;$dsk.tag = $_.tag;$alldisks[$_.tag] += $dsk}
$strAllDisks = ""
$alldisks.Getenumerator() | sort value[1] | %{$strAllDisks+="("+$_.value.bay+";"+$_.value.model+";"+($ -replace "\s *", " ").trim() +")"}
$RaidDisks | %{Add-Member -inputobject $_ -MemberType noteproperty -Name bay -Value $alldisks[$_.disk].bay}
$RaidDisks | %{$di=$;$fn=($StorageVolume | where {$_.deviceid -eq $di}).elementname;Add-Member -inputobject $_ -MemberType noteproperty -Name FullName -Value $fn}
$Raid_configuration = ""
foreach ($lv in ($RaidDisks | sort raid -Unique)) {
$dd = $lv.FullName+"("
($RaidDisks | where {$ -eq $} | select raid,bay| sort bay) |  %{$dd+=$_.bay+","}
$dd = $dd.trimend(",")
$dd += ")"
$Raid_configuration +=$dd+"; "
	$cd.HDD_Raid_Configuration = $Raid_configuration.trimend("; ")

Get-WmiObject -class HPSA_DriveCage -computername $strComputer -namespace "root\HPQ" -ErrorAction SilentlyContinue -credential $cred| select drivebays | %{$hdd_bays+=$_.drivebays}
$cd.HDD_Configuration = $strAllDisks
$cd.No_HDD_Bays_Used = $alldisks.count
$cd.No_HDD_Bays = $hdd_bays



  1. Peter

    Hi there,
    I have tried your script but unfortunately it did not work – I got no data back from the ‘Get-WmiObject -class HPSA_StorageVolume -computername $strComputer -namespace “root\HPQ” ‘ query.
    Do you know of any other way of accessing the date from an array controller through wmi query and powershell. I would be very interested in working with you on a solution as I have a practical use for the script.
    Peter Server Fixes

    1. mihai

      Hi Peter,

      Do you have the HP WBEM provider installed ? You can use WMI Explorer ( to verify if namespace exists and has all the classes.
      Also, you can try locally on the server first by removing -computername parameter.


  2. Anthony Cohn


    Thank you for this script, one thing I corrected though was the line “$ = $strComputer” which I changed to “$ = $strComputer”.


Leave a Reply

Your email address will not be published. Required fields are marked *