Getting data in and out of PowerShell is a critical part of using the language. There are a number of commands dedicated to this task by default.
Importing, exporting, and converting
The Export-Csv command
The Export-Csv command writes data from objects to a text file, for example:
Get-Process | Export-Csv processes.csv
By default, Export-Csv will write a comma-delimited file using ASCII encoding and will completely overwrite any file using the same name.
Export-Csv may be used to add lines to an existing file using the Append parameter. When the Append parameter is used, the input object must have each of the fields listed in the CSV header or an error will be thrown unless the Force parameter is used:
PS> Get-Process...