October 7th, 2014

PowerTip: Put Array of Letters Back into a Word with PowerShell

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to put an array of letters back together to form a word.

Hey, Scripting Guy! Question I split a word by converting it to a chararray, and now I want to put it back together.
           How can I use Windows PowerShell to do this?

Hey, Scripting Guy! Answer Use the –Join operator to put the characters back together. To convert it back to a string,
           add the ToString method, for example:

$a = "dog".ToCharArray() 

($a -join '').tostring() 

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.