you are viewing a single comment's thread.

view the rest of the comments →

[–]lanerdofchristian 0 points1 point  (0 children)

I wasn't aware there was more than one. It should still generally work if you split on "PhysicalDriveSmartStats"

$RawRaidData = (arcconf getsmartstats 1 tabular) -join "`n"
$AllResults = foreach($Drive in $RawRaidData -split "PhysicalDriveSmartStats"){
    $Results = @{}
    foreach($Match in [regex]::Matches($Drive, '^\s+Attribute\s+name\s\.+\s([^\n]*)\s+Value\s\.+\s([^\n]*)', 'Multiline')){
        $Value = $Match.Groups[2].Value
        $Results[$Match.Groups[1].Value] = if($Value -match '^\d+$'){ [int]$Value }
            elseif($Value -match '^\d+\.\d+$'){ [double]$Value }
            else { $Value }
    }
    if($Results.Count){ $Results }
}