formating output

$data= Get-WMIObject  -ComputerName $computers Win32_LogicalDisk `
| select DriveType, VolumeName, Name, {($_.size/1gb)},{($_.freespace/1gb)},{($_.freespace/$_.size*100)}`

Write-Output $data

gets me 

DriveType                  : 3
VolumeName                 : 
Name                       : C:
($_.size/1gb)              : 97.6533164978027
($_.freespace/1gb)         : 73.4033164978027
($_.freespace/$_.size*100) : 75.1672540475923

DriveType                  : 5
VolumeName                 : SQLServer
Name                       : D:
($_.size/1gb)              : 3.63286781311035
($_.freespace/1gb)         : 0
($_.freespace/$_.size*100) : 0

DriveType                  : 3
VolumeName                 : sql
Name                       : E:
($_.size/1gb)              : 299.997066497803
($_.freespace/1gb)         : 299.408504486084
($_.freespace/$_.size*100) : 99.803810744355

how can i get it so this outputs in a comma delimmeted row? 

July 14th, 2015 10:29pm

Hello,

$data | export-csv file.csv

replace the file name with your desired location and file name. like c:\temp\diskinfo.csv

Regards,

Free Windows Admin Tool Kit Click here and download it now
July 14th, 2015 10:46pm

Hi,

Can you give an example of what you want your output to look

July 14th, 2015 10:46pm

Get-WMIObject  -ComputerName $computers Win32_LogicalDisk |
    select DriveType, VolumeName, Name, {($_.size/1gb)},{($_.freespace/1gb)},{($_.freespace/$_.size*100)} |
    Format-Table -Auto

Try not to use run-on sentences.  They make things hard to read and make the script break e

Free Windows Admin Tool Kit Click here and download it now
July 15th, 2015 5:30am

here is what id like the output to look like

3,,C:,97.6533164978027,73.4033164978027,75.1672540475923
5,SQLServer,D:,3.63286781311035,0,0
4,sql,E:,299.997066497803,299.408504486084,99.803810744355

July 15th, 2015 10:22am

I thought you wanted a table.  That is neither a table nor a CSV.

You can customize the output with a select-object statement.

help select-object -full

Look at how to use calculated/computed properties.

YOU could also dump to a CSV and remove the headers.

Free Windows Admin Tool Kit Click here and download it now
July 15th, 2015 11:13am

yeah that works thanks !
July 15th, 2015 11:29am

Cheers, you're very welcome. Glad it worked out.
Free Windows Admin Tool Kit Click here and download it now
July 15th, 2015 12:27pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics