PowerShell -split on Pipe Character PowerShell -split on Pipe Character powershell powershell

PowerShell -split on Pipe Character


It seems -split expects a regular expression and thus you need to escape the pipe as in:

$row = $_ -split "\|"

Or specify the SimpleMatch option to split on the literal string or character:

$row = $_ -split "|", 0, "SimpleMatch"

The 0 stands for MaxSubstrings: "The maximum number of substrings, by default all (0)."

Source: http://ss64.com/ps/split.html
Also: Get-Help about_Split