Windows: Get Disk Smartparameter and Health status

Hi,

in newer Versions of the Windows operating system you to not need additional tools to get the most important Harddisk smart parameters.

An overall state of the disks gets the following query. For all supported drives an Property PredictFailure is added.

$aDisks=Get-WmiObject -namespace root\cimv2 -class Win32_DiskDrive
$aDisks | % {
   $oFailurePredictStatusDisk=Get-WmiObject -Namespace "root\wmi" -query ("select * from MSStorageDriver_FailurePredictStatus where InstanceName like'"+$_.PNPDeviceID.Replace("\","\\")+"%'")
   if($oFailurePredictStatusDisk)
   {
       Add-Member -memberType NoteProperty -InputObject ($_) -Name PredictFailure -Value $oFailurePredictStatusDisk.PredictFailure
   }
}
PS C:\> $aDisks|ft -AutoSize Model,DeviceID,PredictFailure

Model                     DeviceID           PredictFailure
-----                     --------           --------------
Samsung SSD 860 EVO 250GB \\.\PHYSICALDRIVE1          False
SanDisk Ultra USB Device  \\.\PHYSICALDRIVE2
SATA SSD                  \\.\PHYSICALDRIVE0          False

And with some more details

$aAddProperty=@("ReadErrorsCorrected","ReadErrorsTotal","Temperature","PowerOnHours","ReadLatencyMax","WriteLatencyMax","Wear")
$aDisks=Get-WmiObject -namespace root\cimv2 -class Win32_DiskDrive
$aDisks | % {
   $oFailurePredictStatusDisk=Get-WmiObject -Namespace "root\wmi" -query ("select * from MSStorageDriver_FailurePredictStatus where InstanceName like'"+$_.PNPDeviceID.Replace("\","\\")+"%'")
   if($oFailurePredictStatusDisk)
   {
       Add-Member -memberType NoteProperty -InputObject ($_) -Name PredictFailure -Value $oFailurePredictStatusDisk.PredictFailure
   }
   $oStorageReliability=Get-PhysicalDisk -DeviceNumber $_.Index|Get-StorageReliabilityCounter
   foreach($sProperty in $aAddProperty)
   {
       Add-Member -memberType NoteProperty -InputObject ($_) -Name $sProperty -Value $oStorageReliability.$sProperty
   }
}
PS C:\> $aDisks|ft -AutoSize Model,DeviceID,PredictFailure,ReadErrorsTotal,ReadErrorsCorrected,PowerOnHours

Model                     DeviceID           PredictFailure ReadErrorsTotal ReadErrorsCorrected PowerOnHours
-----                     --------           -------------- --------------- ------------------- ------------
Samsung SSD 860 EVO 250GB \\.\PHYSICALDRIVE1          False               0                   0          303
SanDisk Ultra USB Device  \\.\PHYSICALDRIVE2
SATA SSD                  \\.\PHYSICALDRIVE0          False                                              409
Advertisment to support michlstechblog.info

Time limit is exhausted. Please reload CAPTCHA.

Original Theme by Schiy · Powered by WordPress