August 27th, 2012

PowerTip: A Couple Quick PowerShell Array Tricks

Doctor Scripto
Scripter

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

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.