Search code examples
wmiwql

WMI Associators of DiskDrive Where Result Class is MSStorageDriver


Trying to link DiskDrives found in Win32_DiskDrive with the data in MSStorageDriver_ATAPISmartData.

I've tried the following WQL statement, but it returned nothing each time. (I know that there is relevant data in the MSStorageDrive class)

ASSOCIATORS OF {Win32_DiskDrive.DeviceID=[value]} WHERE RESULTCLASS = MSStorageDriver_ATAPISmartData

Any ideas to match the data up?


Solution

  • The answer was this:

    SELECT * FROM MSStorageDriver_ATAPISmartData WHERE InstanceName='[PNPDeviceID]'

    Just make sure to double-escape any backslashses. So if the PNPDeviceID as found in Win32_DiskDrive was

    IDE\DISKHITACHI_HDT725050VLA360_________________V56OA7EA\5&276E2DE5&0&1.0.0

    what would be returned by getting the value will be

    IDE\\DISKHITACHI_HDT725050VLA360_________________V56OA7EA\\5&276E2DE5&0&1.0.0

    but what you need to send in the WHERE clause is

    IDE\\\\DISKHITACHI_HDT725050VLA360_________________V56OA7EA\\\\5&276E2DE5&0&1.0.0

    Silly, isn't it?

    Oh, and from what I've gathered, you also need _0 on the end of the Device ID, so all together, you would send:

    SELECT * FROM MSStorageDriver_ATAPISmartData WHERE InstanceName='IDE\\\\DISKHITACHI_HDT725050VLA360_________________V56OA7EA\\\\5&276E2DE5&0&1.0.0_0'