PowerShell Now! How to get all the characters from a PowerShell string
Oct 10, 2022
TL;DR [char[]]$String
The first in a series of useful things in PowerShell.
The problem was how can I get all the characters in a string so I can process them. It’s not often needed, for example when converting between file formats, but when you do need it there’s little on the web on how to do it.
So I wrote a function, and as I wrote it the answer became obvious.
The name of the function ConvertTo-CharArray, and as PowerShell support type casting:
So in essence all you need is:
TL;CR [char[]]$String