PowerShell: determine folder, disk and volume sizes & free space

Getting folder, disk and volume sizes via powershell van be a pain in the but. However here are some scripts that might mike life a litle more easier.
The first script queries a computername. It then selects the C: drive on which to query against.

$disk = Get-WmiObject Win32_LogicalDisk -ComputerName $computername -Filter “DeviceID=’C:’” |
Select-Object Size,FreeSpace

The second script you can use locallay or when using a remote psssesion. First the path has been defined and then the total size is measured.
You can easily use this to determine a folders size.

“{0:N2}” -f ((Get-ChildItem -path C:\clusterstorage\volume1 -recurse | Measure-Object -property length -sum ).sum /1MB) + ” MB”

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *