PowerShell for Windows Admins

Jan 8 2010   1:44PM GMT

Disks Part 3



Posted by: Richard Siddaway
Tags:
Disks

 

We have seen how to use Win32_DiskDrive to look at our physical disks but this isn’t the whole story. We also need to consider logical disks or volumes

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
$dtype = DATA {
ConvertFrom-StringData -StringData @’
0 = Unknown
1 = No Root Directory
2 = Removable Disk
3 = Local Disk
4 = Network Drive
5 = Compact Disk
6 = RAM Disk
‘@

}

$media = DATA {
ConvertFrom-StringData -StringData @’
11 = Removable media other than floppy
12 = Fixed hard disk media
‘@

}

Get-WmiObject -Class Win32_LogicalDisk | 
Format-List DeviceID, Compressed, Description,
@{Name="Drive Type"; Expression={$dtype["$($_.DriveType)"]}},
@{Name="Media Type"; Expression={$media["$($_.MediaType)"]}},
FileSystem, 
@{Name="Disk Size (GB)"; Expression={"{0:F3}" -f $($_.Size/1GB)}},
@{Name="Free Space (GB)"; Expression={"{0:F3}" -f $($_.FreeSpace/1GB)}},
SupportsDiskQuotas,
SupportsFileBasedCompression,
VolumeName,
VolumeSerialNumber

We have a class called Win32_LogicalDisk for that. The properties are named so they are self explanatory. There are a couple of lookups to replace numeric values with text and a couple of calculations. 

When you run this notice that we get information for CD drives as well – but we don’t on the physical disks. One of the nice pieces of consistency in WMI!

The problem we face next is how to link our physical disk information with our logical disk information i.e. which logical disks are on which physical disk.

Technorati Tags: ,,

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: