$ServerList = Get-Content -Path C:sampleServerList.txt
$Results = foreach($Server in $ServerList){
$Memory = (Get-CimInstance -ClassName CIM_PhysicalMemory -ComputerName $Server | Measure-Object -Property Capacity -Sum).Sum / 1GB
$Disks = Get-CimInstance cim_LogicalDisk -ComputerName $Server | Where-Object -Property DriveType -EQ -Value 3
$DriveC = $Disks | Where-Object -Property DeviceID -EQ -Value 'C:'
$DriveD = $Disks | Where-Object -Property DeviceID -EQ -Value 'D:'
[PSCustomObject]@{
Server = $Server
'PhysicalMemmory(GB)' = $Memory
'C: (GB)' = [MATH]::Round( [LONG]($DriveC | Select-Object -ExpandProperty Size) / 1GB, 0)
'Free Space on C: (GB)' = [MATH]::Round( [LONG]($DriveC | Select-Object -ExpandProperty FreeSpace) / 1GB, 0)
'Free Space on C: (%)' = [MATH]::Round([MATH]::Round( [LONG]($DriveC | Select-Object -ExpandProperty FreeSpace) / 1GB, 0) * 100 / [MATH]::Round( [LONG]($DriveC | Select-Object -ExpandProperty Size) / 1GB, 0), 0)
'D: (GB)' = [MATH]::Round( [LONG]($DriveD | Select-Object -ExpandProperty Size) / 1GB, 0)
'Free Space on D: (GB)' = [MATH]::Round( [LONG]($DriveD | Select-Object -ExpandProperty FreeSpace) / 1GB, 0)
'Free Space on D: (%)' = [MATH]::Round([MATH]::Round( [LONG]($DriveD | Select-Object -ExpandProperty FreeSpace) / 1GB, 0) * 100 / [MATH]::Round( [LONG]($DriveD | Select-Object -ExpandProperty Size) / 1GB, 0), 0)
}
}
$Results | Format-Table -AutoSize