Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell 3.0 : Alternative to "Get-Volume"

I'm trying to get various properties for each hdd-volume on the computer.

I was using the cmdlet get-volume and then walking through it via foreach, but that cmdlet does not exist in Windows Server 2008. :(

Does anybody know an alternative?

I just need the drive letter, objectId/guid, free space, total space, and the name of each volume.

like image 625
Erik Mandke Avatar asked Oct 02 '14 19:10

Erik Mandke


1 Answers

The WMI class Win32_Volume has the information you are looking for

Get-WMIObject -Class Win32_Volume | Select DriveLetter,FreeSpace,Capacity,DeviceID,Label

Which a little fancy footwork you can make the drive space properties looking a little more appealing.

Get-WmiObject -Class Win32_Volume | 
        Select DriveLetter,
            @{Label="FreeSpace (In GB)";Expression={$_.Freespace/1gb}},
            @{Label="Capacity (In GB)";Expression={$_.Capacity/1gb}},
            DeviceID,Label |
        Format-Table -AutoSize
like image 141
Matt Avatar answered Sep 28 '22 02:09

Matt