<<< Back to Search

Concatenate multiple Arrays

On this example two Arrays are being merged into one

Example

# Declare Arrays
$array1 = @("test1-array1", "test2-array1", "test3-array1")
$array2 = @("test4-array2", "test5-array2")

# Concatenate Arrays
$arrayConcatenated = $array1 + $array2

# Write array piping output 
Write-Host "`r`nWrite array piping output:`r`n"
$arrayConcatenated | Out-String | Write-Host


Output

PS C:\> 

Write array piping output:

test1-array1
test2-array1
test3-array1
test4-array2
test5-array2