powershell: How to check if S.M.A.R.T is enabled on remote machines
"When the road before you splits in two, take a third path..." ~ Telaxian Proverb
Script
This is the script I used to get the SMART data from multiple machines. I've already enabled winrm
on the devices used in this example.
$aComputers = Get-Content C:\ComputerSMARTDriveTest.txt
(Get-WmiObject -ComputerName $aComputers -namespace root\wmi –class MSStorageDriver_FailurePredictStatus -ErrorAction Silentlycontinue |
more |
Select PSComputerName,PredictFailure,Reason,InstanceName |
Format-Table –Autosize)
That will get you output like:
PSComputerName PredictFailure Reason InstanceName
-------------- -------------- ------ ------------
4CZ1***** False 0 IDE\DiskHitachi_HTS723225A7A364_________________ECBOA60W\4&35e86db3&0...
2UA0***** False 0 IDE\DiskST3160318AS_____________________________HP35____\5&5df8cfa&0&...
Script Notes:
In the text file I have one hostname listed per line. There are no comma's separating the data. Also, computers which don't have smart enabled drives won't show on the report. You can customize the report with more data options to select, just run a Select *
instead of the options I used in the script to see the full dump.
Win32_diskdrive vs MSStorageDriver_FailurePredictStatus
On the question of win32_diskdrive
vs MSStorageDriver_FailurePredictStatus
properties... The MSStorageDriver_FailurePredictStatus
is in the dynasty of MSStorageDriver
in the root\wmi
namespace (which is separate and distinct from root\cimv2
where the class win32_diskdrve
exists) and get's it's non class specific properties from inheritance. The MSStorageDriver
gets it's data direct from the hardware (no provider). Where as win32_diskdrive
has it's own PNPDeviceID
property which uses the provider Win32_DiskDrivePhysicalMedia
. Both query the same data from the hardware but do so separately.
That script above where it gets the InstanceName
is the same as PNPDeviceID
below:
(Get-WmiObject -ComputerName $aComputers -Namespace root\cimv2 -Class win32_diskdrive `
-ErrorAction Continue |
more |
select PNPDeviceID |
Format-Table -AutoSize)
Conclusion
(gwmi -Namespace root\wmi -Class MSStorageDriver_FailurePredictStatus).InstanceName
Get's the same data as:
(gwmi -Class Win32_DiskDrive).PNPDeviceID
Comment References
This section contains links intended to reference additional information from the comment section of this answer.
Device Tree
Instance IDs