$deviceid = (gwmi win32_logicaldisk -filter "Name='$drvltr'").` GetRelated('Win32_DiskPartition').GetRelated('Win32_DiskDrive') | foreach { $_.PNPDeviceID } $predict = gwmi -Namespace root\wmi -class MSStorageDriver_FailurePredictStatus | Where-Object { $_.InstanceName -like "$deviceid*" } | foreach { $_.PredictFailure }
I use the above code to get PredictFailure status for each volume as part of an inventory script. The problem is not all drives support SMART. What is the best way to test/handle this to avoid throwing an error?
The error I get is this:
gwmi : Not supported... $Predict = gwmi -Namespace root\wmi -class MSStorageDriver_FailurePredictStatus... +CategoryInfo : Invalid Operation [Get-WmiObject], ManagementException..