Identifying Hard disk type

Hi,

I’m trying to determine what type of Hard drive types my computers have, so i wrote the following:

q: if (select “MediaType FROM MSFT_PhysicalDisk” of wmis “ROOT\Microsoft\Windows\Storage” as string) contains “4” as string then “SSD” else if (select “MediaType FROM MSFT_PhysicalDisk” of wmis “ROOT\Microsoft\Windows\Storage” as string) contains “3” as string then “HDD” else if (select “MediaType FROM MSFT_PhysicalDisk” of wmis “ROOT\Microsoft\Windows\Storage” as string) contains “0” as string then “Unspecified” else nothing
A: SSD
T: 164.627 ms
I: plural string

this works great, but only for computers with only one hard drive.

if I use “selects” instead of “Select” i get “A singular expression is required.” error.
how can I write it in a way that will display multiple results in a friendly name?

Thanks!

I’m sure there are neater ways but 1 possible approach

Q: (if (it = "0") then ("Unspecified") else ((if (it = "3") then ("HDD") else ((if (it = "4") then ("SDD") else ((if (it = "5") then ("SCM") else ("Unknown")))))))) of (string values of selects "MediaType FROM MSFT_PhysicalDisk" of wmis "ROOT\Microsoft\Windows\Storage" as string)
A: SDD
A: SDD
A: HDD
4 Likes

That works, Thanks!

usually I don’t like using WMI as its a heavy query, and it can be done with PowerShell (Get-PhysicalDisk | Select MediaType) but that would require a 2-step approach (write the output to a file or registry, and a property to read it) so I was forced to use WMI.

Thanks again!

1 Like

Thanks for this but does this work on multiple harddrive and ssd

The example was being evaluated on a machine with 2 SSD and 1 HDD so I’d say yes. :grin:

1 Like