According to win32_volume class documentation here the device name that shows up under device manager is is unavailable as a property of win32_volume. Is the SerialNumber property unique to the device or only to she system? If only to the system what property should I look for to write a portable script?
Answer
The SerialNumber will see you right. The DeviceID property also looked promising, but that is only static on the one system.
To test I inserted two USB Drives and ran the following command in PowerShell:
Get-WmiObject -Class Win32_Volume | select Name, DeviceID, SerialNumber
The initial output looked like this:
Name DeviceID SerialNumber
---- -------- ------------
J:\ \\?\Volume{56f4971c-28d3-11e5-8298-10604b833008}\ 1893178287
H:\ \\?\Volume{56f496cc-28d3-11e5-8298-10604b833008}\ 3930884954
I ejected both and re-inserted them in the opposite order hoping that they would swap drive letters, however they retained them, but swapped position in the PowerShell output. (note that DeviceID and SerialNumber are the same.)
Name DeviceID SerialNumber
---- -------- ------------
H:\ \\?\Volume{56f496cc-28d3-11e5-8298-10604b833008}\ 3930884954
J:\ \\?\Volume{56f4971c-28d3-11e5-8298-10604b833008}\ 1893178287
Finally I inserted the sticks into another computer, note that the deviceId is different, but the serial number remains the same.
Name DeviceID SerialNumber
---- -------- ------------
E:\ \\?\Volume{603a0c09-2674-11e5-b1db-0050569a754c}\ 3930884954
H:\ \\?\Volume{603a0c15-2674-11e5-b1db-0050569a754c}\ 1893178287
No comments:
Post a Comment