PowerShell How To Join / Concatenate Strings
Two strings that we would like to join or concatenate.
$a = "test1" $b = "test2"
Concatenate and output two strings saved as variables:
$a + $b
Concatenate and output three strings ( 2 variables and one literal ):
$a + " " + $b
Same except save these to a variable and output that:
$c = $a + " " + $b $c
PowerShell Join Strings
Join two strings each on a separate line:
-join $a, $b
Join two strings on the same line ( no space ):
-join ($a, $b)
Join three strings ( 2 variables and one literal ):
-join ($a, " ", $b)