I have a PS script to search a single Server to get logicaldisks with free space.
I want to change this script so I can get multiple Servers logical disks with them formated by servername
I am NOT good at foreach statements what am I doing wrong?
$Servers = Get-Content "C:\servers.txt"
foreach ($ComputerName in $Computers) {
Get-WmiObject Win32_logicaldisk -$ComputerName $Servers `
| Format-Table DeviceID, MediaType, `
@{Name="Size(GB)";Expression={[decimal]("{0:N0}" -f($_.size/1gb))}}, `
@{Name="Free Space(GB)";Expression={[decimal]("{0:N0}" -f($_.freespace/1gb))}}, `
@{Name="Free (%)";Expression={"{0,6:P0}" -f(($_.freespace/1gb) / ($_.size/1gb))}} `
-AutoSize
}