public/Show-OctaDiskHealth.ps1
|
function Show-OctaDiskHealth { <# .SYNOPSIS Read-only per-physical-disk S.M.A.R.T./reliability report via the built-in Storage module. Each field is reported "not available" independently when the underlying counter is absent - confirmed a real, per-field (not just per-disk) occurrence on real hardware during research.md, not a hypothetical edge case. research.md: the piped form (`Get-PhysicalDisk | Get-StorageReliabilityCounter`) returns real data; the `-PhysicalDisk <obj>` parameter form did not in testing. #> [CmdletBinding()] param() $disks = @(Get-PhysicalDisk -ErrorAction SilentlyContinue) $counters = @($disks | Get-StorageReliabilityCounter -ErrorAction SilentlyContinue) $report = @( foreach ($disk in $disks) { $counter = $counters | Where-Object { $_.DeviceId -eq $disk.DeviceId } | Select-Object -First 1 [pscustomobject]@{ FriendlyName = $disk.FriendlyName MediaType = $disk.MediaType HealthStatus = $disk.HealthStatus TemperatureC = if ($counter -and $null -ne $counter.Temperature) { $counter.Temperature } else { 'not available' } PowerOnHours = if ($counter -and $null -ne $counter.PowerOnHours) { $counter.PowerOnHours } else { 'not available' } Wear = if ($counter -and $null -ne $counter.Wear) { $counter.Wear } else { 'not available' } } } ) foreach ($r in $report) { Write-Host ("{0,-24} {1,-8} {2,-8} {3,-6} {4,-14} {5}" -f $r.FriendlyName, $r.MediaType, $r.HealthStatus, $r.TemperatureC, $r.PowerOnHours, $r.Wear) } return $report } |