How to Write a Variable to a CSV File in PowerShell
To write a variable to a CSV file in PowerShell, put the values in a [pscustomobject] and pipe it to Export-Csv. Each property becomes a column: Piping a plain string or a hashtable gives you a surprising file instead. Below I show what goes wrong, and how to write strings, arrays, hashtables and loop results … Read more