ConvertTo-CSV
creates a CSV representation from
PowerShell objects: Each object becomes a row (or record), each member of the object a field (or value) in the record.
The following example uses
get-process
to obtain a list of PowerShell objects each of which represents a process and then
pipes those object into
select-object
to select the objects' properties of interest and then finally pipes the result to
convertTo-CSV
for a CSV output:
Delimiter
By default, convertTo-csv
delimites the fields with a comma. The -delimiter
option allows to specify a different character.
Because the semicolon has a special meaning in
PowerShell, it must be put in quotes or escaped with the backslash:
… | convertTo-csv -delimiter ';'
… | convertTo-csv -delimiter `;
Similarly, a tabulator can be specified with by escaping t
:
… | convertTo-csv -delimiter `t