PowerTip: A Couple Quick PowerShell Array Tricks

Summary:  Learn some quick tricks for using Windows PowerShell arrays.

Hey, Scripting Guy! Question How can I split the following string in the $a variable?

$a = “atl-ws-01,atl-ws-02,atl-ws-03,atl-ws-04”

Hey, Scripting Guy! Answer Use the split method :

$b = $a.split(“,”)

 

Hey, Scripting Guy! Question How do I join an array, such as the one in the $a variable shown here?

 $a = “h”,”e”,”l”,”l”,”o”

Hey, Scripting Guy! Answer Use the join static method from the string c