Tuesday, 27 September 2022

In powershell how to output an ArrayList to CSV

 In powershell how to output an ArrayList to CSV

 

$CSVArrayList = new-Object System.Collections.ArrayList

[void]$CSVArrayList.Add(@('1','2','3'))
[void]$CSVArrayList.Add(@('4','5','6'))

Set-Content "./Output.csv" -Value $null

Foreach ($arr in $CSVArrayList) {
      $arr -join ',' | Add-Content "./Output.csv"
}

 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.