kayasax
4/13/2015 - 8:49 AM

powershell Array collection to CSV

powershell Array collection to CSV

$col=@()
#...
# instead adding an hashtable to the collection, we convert it to psobject 
$prop=@{"serveur"="$computername";"nom"="$n";"programme"="$p";"arguments"="$a";	"xml"="$x"}
$col+= new-object -type pscustomobject -property $prop

#this allow us to export data to csv
$r |select serveur,nom,programme, arguments,xml |export-csv -path c:\temp\tasks.csv -notype -delimiter ';' -append