Powershell 3.0 : Alternative to "Get-Volume"

13,838

Solution 1

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

Solution 2

Get-Volume is only in Powershell 4.

You can do this tho:

Get-WmiObject Win32_LogicalDisk | Select-Object DeviceID, Size, FreeSpace, VolumeName
Share:
13,838
Erik Mandke
Author by

Erik Mandke

Hi there! I am a software-developer from germany. I usually use C#/WPF/ASP.net(webforms/mvc) to write web- and desktop/server applications. I use SQL-Server as primary database management system - currently learning for certification. Im am interested in working with windows-server and linux-server as well.

Updated on June 21, 2022

Comments

  • Erik Mandke
    Erik Mandke almost 2 years

    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.