This post has the command I needed.
However, I was unable to get the desired result in a table format as my version of Powershell did not support Out-GridView.
Wrote the following script and saved it as FindSpace.ps1
Clear-Host
$ExchServerList = Get-Content Servers.txt
foreach( $ExSrv in $ExchServerList)
{
Get-WMIObject Win32_LogicalDisk -filter “DriveType=3” -computer $ExSrv | ? {$_.DeviceID -like “C:”} | Select SystemName,VolumeName,@{Name=”Size(GB)”;Expression={[decimal](“{0:N1}” -f($_.size/1gb))}},@{Name=”Free Space(GB)”;Expression={[decimal](“{0:N1}” -f($_.freespace/1gb))}},@{Name=”Free Space(%)”;Expression={“{0:P2}” -f(($_.freespace/1gb) / ($_.size/1gb))}}
}
.\FindSpace.ps1 | ft -auto > Result.txt gave me the result I needed.
Note: The command inside {} is a single line one.
– Thanks, Jinesh.
Getting error as “Unexpected token ‘:N1’ in expression or statement.”
Hi Vivek,
It could be a formatting issue. Can you copy the script to Notepad first and look for any issues? Once you have corrected the quotes (that’s what I assume went wrong) it should work fine.
Jinesh