PowerTip: Concatenate String Array with PowerShell


Summary: Use Windows PowerShell to concatenate elements of a array.

Hey, Scripting Guy! Question How can I use Windows PowerShell to concatenate the elements of a string array?

Hey, Scripting Guy! Answer Use the static Concat method from the String class, for example:

$a = "string a"

$b = "string b"

$arr = @($a,$b)

[string]::Concat($arr)

Comments (4)

  1. B Josephs says:

    @ PetSerAl
    +1

  2. Matt says:

    or without array: [string]::Concat($a,$b)

  3. James A. Brown says:

    Perhaps the simplest non-array option:

    $a + $b

Skip to main content