CSVs with Alternative Delimiters

by Aug 24, 2009

In PowerShell V1, creating CSVs wasn't very flexible because PowerShell was limited to the comma as separator. In many cultures, different separators (like semicolons or tabs) are used instead.

With PowerShell V2, you now have a choice and can specify any one-character-delimiter. So finally, things work well on international systems as well. Let's take a German machine with Office Excel installed. In that culture, excel uses a semicolon as separator. If you create a default CSV and try to open it with excel, excel will not identify columns correctly. In PowerShell V2, by specifying the appropriate separator, all is fine now:

Get-Service | Export-CSV $home\services.csv -Delimiter ';'
. "$home\services.csv"

Provided you run this on a system with German locale (or any culture that uses ";" as default separator) and have excel installed, you will get a nice spreadsheet with all service details.

Twitter This Tip! ReTweet this Tip!