Convert an Array Object to a String in PowerShell
-
Use
" "
to Convert an Array Object to String in PowerShell -
Use the
join
Operator to Convert an Array Object to a String in PowerShell - Use the Explicit Conversion to Convert an Array Object to a String in PowerShell
-
Use the
Output Field Separator
Variable to Convert an Array Object to a String in PowerShell -
Use
[system.String]::Join(" ", $array)
to Convert an Array Object to a String in PowerShell

PowerShell has multiple data types: string, integer, array, boolean, DateTime
, etc. This tutorial will introduce different methods to convert an array object to string in PowerShell.
Use " "
to Convert an Array Object to String in PowerShell
Double inverted commas " "
denote a string in PowerShell. You can use the same method to convert an array object to a string data type.
Suppose we have an array object $address
.
$address = "Where", "are", "you", "from?"
You can check the data type using the GetType()
method.
$address.GetType()
Output:
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
When you encode the array variable with " "
, it will be converted into a string.
"$address"
Output:
Where are you from?
Check the data type:
"$address".GetType()
Output:
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
Use the join
Operator to Convert an Array Object to a String in PowerShell
The join
operator is another method to convert an array object to a string. It helps to join the array of items with specific characters, numbers, or letters.
$address -join "+"
Output:
Where+are+you+from?
Let’s check the data type.
$a = $address -join "+"
$address.GetType().Name
Output:
Object[]
Use the Explicit Conversion to Convert an Array Object to a String in PowerShell
You can explicitly convert an array object to a string by casting it to a string data type.
For example:
[string]$address
Output:
Where are you from?
Use the Output Field Separator
Variable to Convert an Array Object to a String in PowerShell
The Output Field Separator variable $OFS
helps convert an array object to a string in PowerShell.
You can follow the same steps below.
$OFS = '-'
"$address"
Output:
Where-are-you-from?
Use [system.String]::Join(" ", $array)
to Convert an Array Object to a String in PowerShell
The following command also joins the items of an array to convert them to a string.
[system.String]::Join(" ", $address)
Output:
Where are you from?
Related Article - PowerShell String
- Array of Strings in PowerShell
- Check if a File Contains a Specific String Using PowerShell
- Extract a PowerShell Substring From a String
- Extract Texts Using Regex in PowerShell
- Generate Random Strings Using PowerShell
- Escape Single Quotes and Double Quotes in PowerShell
Related Article - PowerShell Array
- Array of Strings in PowerShell
- Create an Empty Array of Arrays in PowerShell
- Byte Array in PowerShell
- Pass an Array to a Function in PowerShell
- Sorting Array Values Using PowerShell
- Count the Length of Array in PowerShell