Author Posts

November 9, 2016 at 9:50 am

$computername = Get-Content C:\scripts\comps.txt
foreach ($computer in $computername){
Get-WmiObject Win32_LogicalDisk -filter "DriveType=3" -computer $computer |
Select SystemName,DeviceID,VolumeName,@{Name="Size(GB)";
Expression={"{0:N1}" -f($_.size/1gb)}},@{Name="FreeSpace(GB)";
Expression={"{0:N1}" -f($_.freespace/1gb)}},@{Name="LOW SPACE";
Expression={"{0:N1}" -f($_.freespace / $_.size -lt .2)}} }
____________________________
How do I get the report like below
Srv1 c: d: E : F :
Srv c: d: E : F :

November 9, 2016 at 8:56 pm

Have you tried format-table?
I can not test it properly because I only have one disk.

 foreach ($computer in $computername){
 Get-WmiObject Win32_LogicalDisk -filter "DriveType=3" -computer $computer |
 Select SystemName,DeviceID,VolumeName,
 @{Name="Size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}},
 @{Name="FreeSpace(GB)";Expression={"{0:N1}" -f($_.freespace/1gb)}},
 @{Name="LOW SPACE";Expression={"{0:N1}" -f($_.freespace / $_.size -lt .2)}}|Format-Table
 }