1 | Get-WmiObject -ComputerName "ServerName" Win32_Volume | select Name,FileSystem,FreeSpace,BlockSize,Capacity | % {$_.BlockSize=(($_.FreeSpace)/($_.Capacity))*100;$_.FreeSpace=($_.FreeSpace/1GB);$_.Capacity=($_.Capacity/1GB);$_} | Sort-Object Name | Format-Table Name,@{n='Free,GB';e={'{0:N2}'-f $_.FreeSpace}},@{n='Free,%';e={'{0:N2}'-f $_.BlockSize}},@{n='Capacity,GB';e={'{0:N3}' -f $_.Capacity}},@{n='FS';e={$_.FileSystem}} -AutoSize |
This cmdlet will list all your mounted volumes, their size, the file system used, and the available free space. You can modify the code to have a where-object statement: ? {$_.Name -like “*logs*”}. This helps if you have an exchange server that has multiple database volumes for DBs and logs and need to quickly find which volume is the culprit.
I also use a lot of these scripts to gather the information quickly so that I can post the output into my incidents that I am working. It’s good to have these handy.
Here is an example output:
Name | Free, GB | Free, % | Capacity, GB | FS |
C:\ExchangeDB\DAG2DB01\DB\ | 456.80 | 37.45 | 1,219.873 | NTFS |
C:\ExchangeDB\DAG2DB01\LOG\ | 39.49 | 99.03 | 39.873 | NTFS |