Mapping Physical Drives to Logical Drives Part 3

Tags:
Following on from last time we will extend our script to pull the information for logical drives.
001
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 |
Get-WmiObject -Class Win32_DiskDrive | foreach {
“`n {0} {1}” -f $($_.Name), $($_.Model) $query = “ASSOCIATORS OF {Win32_DiskDrive.DeviceID='” ` |
When we get the data for the partitions (line 7) we now put that into a foreach loop. The name, description and if its a primary partition are dumped. I’m using a string to write it because we will get a formatting error if we try to use format-list with two different objects in the same script.
A query to get the associators of the partition (as long as its a logical drive) is created and run. The results from that are displayed using the calculated fields we have seen earlier.
That concludes our look at getting information about disks. Next we’ll look at the methods these WMI classes make available – in other words what can we do with them
 Comment on this Post