PowerShell • • 1 min read
Flatten PowerShell Arrays
How to convert a PowerShell array into a single string using -join.
PowerShell
Sometimes I have to flatten a PowerShell array because I need a single string.
A simple way to do it is:
$a = @('Patrick', 'wants', 'a', 'String', ';)')
$a -join ' '
This returns one string value with spaces between the array entries.
So it is an easy and readable way to get a string from an array in PowerShell.