Hello,
I am creating various "hash of array" that I then want to export to CSV.
I just show what seems relevant to my issue.
#...
#feeding the variable in a foreach (get-gpo with some criteria)
$GPO_allsettingsdisabledHASH.add($var.id,@($var.displayname,$var.CreationTime, $var.ModificationTime, $var.Owner))
#...
#exporting the values to my CSV
$GPO_allsettingsdisabledHASH.GetEnumerator() | Sort value | format-table -AutoSize | Out-File "$ReportPath\_UnUsedGPOs_$domain.txt" -Append
$GPO_allsettingsdisabledHASH.GetEnumerator() | Select Name, @{N='Domain';E={$Domain}}, @{N='Reason';E={"All Settings Disabled"}}, @{N='GUID';E={$_.Name}}, @{N='GPO';E={$_.Value}}, @{N='Remove';E={"YES"}} | Sort -property value | Export-Csv -NoTypeInformation -Path "$ReportPath\_UnUsedGPOs_Listing.csv" -Append
The problem there is that all my array goes to only one column.
The closest I could do was using this line below and then tell excel to use comma separator WITHOUT text delimiter (")
It works but it's kind of tricking excel and my columns then don't have any name. I feel there should be a batter way of writing this but I don't know how.
$GPO_allsettingsdisabledHASH.GetEnumerator() | Select Name, @{N='Computers';E={$_.Value -join ", "}} | Export-Csv -NoTypeInformation -Path "$ReportPath\myfile.csv" -Append
Thank you for your help.