Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to access the freespace of the physical drives that make up a storage pool on Windows Server 2012?

I've just recently ran into a problem with running out of space, and can see the space allocated on each drive through the GUI, but can't seem to find a way to script it in Powershell (or vbscript/wmi or cmd), as I want to generate regular reports.

share|improve this question
up vote 2 down vote accepted

The Get-PhysicalDisk cmdlet has the info you need to calculate the free space. Specifically, it returns an object type that contains the following properties:

  • AllocatedSize (e.g. Used Space)
  • Size (e.g. Capacity)

Armed with that knowledge, we can make a basic one-liner to return the free space of all physical drives on the system (ignoring for the moment which ones are members of a virtual disk or storage pool:

Get-PhysicalDisk | Select FriendlyName,Size,@{L='Free Space';E={$_.Size-$_.AllocatedSize}}

But all of the values returned are in Bytes which isn't terribly useful on today's large disks. You probably want to format the results to either GB or TB like so:

Get-PhysicalDisk | Select FriendlyName,@{L='Capacity';E={"{0:N2}GB" -f ($_.Size/1GB)}},@{L='Free Space';E={"{0:N2}GB" -f (($_.Size-$_.AllocatedSize)/1GB)}} | Sort 'Free Space'
Get-PhysicalDisk | Select FriendlyName,@{L='Capacity';E={"{0:N2}TB" -f ($_.Size/1TB)}},@{L='Free Space';E={"{0:N2}TB" -f (($_.Size-$_.AllocatedSize)/1TB)}} | Sort 'Free Space'

So now we've got a command that will nicely list the Capacity and Free Space of all physical disks on the system. But we only want the physical disks that make up a particular storage pool. As it turns out, this is pretty easy with Get-StoragePool and powershell's native object piping:

Get-StoragePool 'MyPool' | Get-PhysicalDisk | Select FriendlyName,@{L='Capacity';E={"{0:N2}TB" -f ($_.Size/1TB)}},@{L='Free Space';E={"{0:N2}TB" -f (($_.Size-$_.AllocatedSize)/1TB)}} | Sort 'Free Space'

You query the disks associated with a virtual disk as well with Get-VirtualDisk:

Get-VirtualDisk 'MyVD' | Get-PhysicalDisk | Select FriendlyName,@{L='Capacity';E={"{0:N2}TB" -f ($_.Size/1TB)}},@{L='Free Space';E={"{0:N2}TB" -f (($_.Size-$_.AllocatedSize)/1TB)}} | Sort 'Free Space'
share|improve this answer
If I get some more time, I'll try to piece together something that will associate these with their parent virtual disk. – Ryan Bolger Jan 17 '14 at 6:26
There we go. Looks like I had more time than I thought. – Ryan Bolger Jan 17 '14 at 6:53
That's brilliant @Ryan Bolger, just what I was looking for :) – r3adm3 Jan 17 '14 at 9:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.