21 June,2021 by Tom Collins
Question: How can I get the capacity & freespace on Windows drives including mount points using Powershell.
Answer: Win32_Volume class “represents an area of storage on a hard disk”. Normally - we may look first at Win32_LogicalDisk class “represents a data source that resolves to an actual local storage device on a computer system running Windows”.
A volume mount point is a drive or volume in Windows that is mounted to a folder that uses the NTFS file system. A mounted drive is assigned a drive path instead of a drive letter. By using volume mount points, you can mount, a target partition onto a folder on another physical disk.
--Get freespace and capacity of every drive & mountpoint on a Windows servers. This will return the figures as bytes
Get-WmiObject Win32_Volume | Format-Table Name, Label, FreeSpace, Capacity
--Get freespace and capacity of every drive & mountpoint on a Windows servers. This will return the figures as GB.
--Added the Round function and limited to 2 decimal points
Get-WmiObject Win32_Volume | Select-Object driveletter,Label,@{Name='freespace';Expression={[math]::Round($_.freespace/1GB,2)}},@{Name='capacity';Expression={[math]::Round($_.capacity/1GB,2)}}
--Add the -computername switch if you need to check remotely
Get-WmiObject Win32_Volume -computername MYCOMPUTER| Select-Object driveletter,Label,@{Name='freespace';Expression={[math]::Round($_.freespace/1GB,2)}},@{Name='capacity';Expression={[math]::Round($_.capacity/1GB,2)}}
Read more on Powershell & disk management
Powershell script to check disk space on remote servers
Powershell script function for disk free
How to master Mount-Diskimage in Powershell
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |