Sunday, January 18, 2009

quick view of free disk space and drive type

[] to return free space information for each local disk in terms of bytes

PS> get-wmiobject -class win32_logicaldisk | ft -auto -Property DeviceId,DriveType,FreeSpace,Size,VolumeName

DeviceId DriveType FreeSpace Size VolumeName
-------- --------- --------- ---- ----------
C: 3 9533083648 20958011392 ACER
D: 3 2435698688 4992708608 MISC
E: 3 28816961536 50668896256 DATA
F: 5 <---- CDROM drive
R: 3 16655360 16694784 RamDisk
S: 5


[] to return free space information for each local disk in terms of GB

PS> Get-WmiObject -Class Win32_LogicalDisk | Select-Object -Property Name,FreeSpace | ForEach-Object -Process {$_.FreeSpace = ($_.FreeSpace)/1024.0/1024.0/1024.0; $_} | ft -auto

Name FreeSpace
---- ---------
C: 8.87826919555664
D: 2.2684211730957
E: 26.8378868103027
F: 0
R: 0.0155115127563477
S: 0

No comments:

Post a Comment