I'm running the below scrpt to return a resultset of disk capacity from a list of all available servers within our estate. I'd like to append the outputs and combine them into one dataset to make it easy to display and interrogate. I am aware of how to append values to an array with one column however as this would require multiple, I'm not sure how to acheive this. Is it possible to append the result set from this output to an array?
$myarray = @("")
$servers =
@(
'SERVER1'
,'SERVER2'
,'SERVER3'
,'SERVER4'
,'SERVER5'
,'SERVER6'
)
$wmiQuery = @"
SELECT
SystemName,Name,DriveType,FileSystem,FreeSpace,Capacity,Label
FROM
Win32_Volume
"@
Foreach ($server in $servers)
{
Get-WmiObject -ComputerName $server -Query $wmiQuery| Select-Object @{Name = "Computer"; Expression={$server}},Name,
Label,
@{Name = "SizeInGB"; Expression={"{0:N2}"-f ($_.Capacity/1GB)}},
@{Name = "UsedSizeInGB"; Expression={"{0:N2}"-f (($_.Capacity - $_.FreeSpace)/1GB)}},
@{Name = "FreeSizeInGB"; Expression={"{0:N2}"-f ($_.FreeSpace/1GB)}},
@{Name = "FreePerc"; Expression={"{0:N2}"-f (($_.FreeSpace/1GB)/($_.Capacity/1GB))}}|Where-Object FreePerc -LE 0.16|Format-Table
}