Hello
I thinks this can help you simplify it:
$serverlist = Get-Content .\servers.txt
Get-WmiObject Win32_Volume -Computer $serverlist |
Select-Object __SERVER, Name, Label, FreeSpace, Capacity |
Export-Csv 'C:\output.csv' -NoType
If you need particular column titles instead of the regular property names or values in a particular format use calculated properties to change that:
Get-WmiObject Win32_Volume -Computer $serverlist |
Select-Object @{n='Server Name';e={$_.__SERVER}}, @{n='Drive';e={$.Name}},
@{n='Disk Name';e={$.Label}},
@{n='FreeSpace';e={'{0} GB' -f int}},
@{n='Capacity';e={'{0} GB' -f int}} |
Export-Csv 'C:\output.csv' -NoType
Best regards,
Luis P