Wednesday, June 19, 2013

Find Free Disk Space for a drive from a list of Servers

In order to get free disk space details for C: Drive of a list of Servers, execute below PS command.

Get-WmiObject -Class Win32_LogicalDisk -ComputerName (Get-Content C:\temp\Servers.txt) -Filter "DeviceId='C:'"|
Format-Table SystemName, @{Name="Free";Expression={[math]::round($($_.FreeSpace/1GB), 2)}},
@{Name="Total Size";Expression={[math]::round($($_.Size/1GB), 2)}} –auto

The list of Servers is stored under C:\temp\Servers.txt.
The output will give the Computername, Total Disk Space and Free Disk Space.

No comments:

Post a Comment