I'm trying to export to csv all disks for each computer from my list. I have computers configured with one, tow of tree disks. Now when I export the result of my script to csv file,I get it in formatted as list format:
ComputerName, Disk
Comp1, C:
Comp1, D:
Comp2, C:
Comp2, D:
I would like to know if it is possible to export this list but as table? If there are more then one disk in computer add a column to the table, something like this:
ComputerName, Disk1, Disk2...
Comp1, C:, D:
Comp2, C:, D:
Comp3, C:
Update:
$computers = 'Comp1','Comp2'
$out_csv =@()
foreach ($computer in $computers) {
$disks = Get-WmiObject -Class win32_logicaldisk -ComputerName $computer| select deviceid, volumename
foreach ($disk in $disks) {
$ou = New-Object -TypeName psobject -Property @{
'Computer' = $computer
'drive' = $disk.volumename
'ID' = $disk.deviceid
}
$out_csv += $ou
}
}
$out_csv | Export-Clixml -Path 'C:\Users\Administrator\disk.csv'