Windows WMI has the classes to extract these information.
Here are some examples.
Hard Disk Drive - Primary - Model
string values of selects “Model from win32_diskdrive where deviceid = ‘\\.\PHYSICALDRIVE0’” of wmi
Hard Disk Drive - Primary - Serial Number
(string values of (selects “SerialNumber from win32_physicalmedia where tag = ‘\\.\PHYSICALDRIVE0’” of wmi)) as trimmed string
Hard Disk Drive - Secondary - Model
if (exists wmi) and (exists selects “Size from win32_diskdrive where deviceid = ‘\\.\PHYSICALDRIVE1’” of wmi) then string values of selects “Model from win32_diskdrive where deviceid = ‘\\.\PHYSICALDRIVE1’” of wmi else “none”
Hard Disk Drive - Secondary - Serial Number
if (exists wmi) and (exists selects “Size from win32_diskdrive where deviceid = ‘\\.\PHYSICALDRIVE1’” of wmi) then (string values of (selects “SerialNumber from win32_physicalmedia where tag = ‘\\.\PHYSICALDRIVE1’” of wmi)) as trimmed string else “none”
(string value of property “PredictFailure” of it & " - " & string value of property “InstanceName” of it) of select objects “* from MSStorageDriver_FailurePredictStatus” of wmi “root\WMI”
I’m using this relevance below and sometimes getting an error back. I see some errors:
Singlular expression refers to nonexistant object - I see this on VM clients
The expression could not be evaluated: Windows Error: unknown error 0x8004100c
The expression could not be evaluated: Windows Error: 8004100c not supported
I only care about the health of the primary drive and every system in the site where i have this analysis only has 1 drive. How can I make the property show something other than error if the drive does not support SMART?
(string value of property “PredictFailure” of it) of select objects “* from MSStorageDriver_FailurePredictStatus” of wmi “root\WMI”
This will show you Not Supported in the case of an error executing the WMI statement:
if ( exists select object "PredictFailure from MSStorageDriver_FailurePredictStatus" of wmi "root\WMI" | false ) then ( ( it as string ) of select objects "PredictFailure from MSStorageDriver_FailurePredictStatus" of wmi "root\WMI" ) else ( "Not Supported" )
As calling any wmi inspector can be very system dependent on how it works you could also have a problem with the OS. For example: http://support.microsoft.com/kb/836802