Using -split with PowerShell

This little -parameter is useful when you have PowerShell output that is delimited with a character. Below is an example using the Env PSProvider where we simply output the value $ENV:path to display the system search path. The first example is hard to read:

PS-Split-1

This is not pretty (or usable)! We can use a parameter that PowerShell provides (-split “;”) that will take a delimiter character that will allows us to splits the lines at each delimiter. The output i much more readable:

PS-Split-2

Much better! We can output the list to a text file if need be for further processing.

Views – 2111

Leave a Reply