Search notes:

PowerShell cmdLet ConvertTo-CSV

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:
get-process | select-object name, id, vm, pm | convertTo-CSV
Github repository about-PowerShell, path: /cmdlets/csv/convertTo/processes.ps1

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

See also

Powershell command noun: CSV

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1758201260, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/PowerShell/command-inventory/noun/CSV/convertTo(55): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78