While expression:
"string1" + "string2" + "string3"
will concatenate the string, you need to put a $ in front of the parenthesis to make it evaluate as a single argument when passed to a PowerShell command. Example:
Write-Host $( "string1" + "string2" + "string3" )
As a bonus, if you want it to span multiple lines, then you need to use the awkward backtick syntax at the end of the line (without any spaces or characters to the right of the backtick).
Example:
Write-Host $(`
"The rain in " +`
"Spain falls mainly " +`
"in the plains" )`
-ForegroundColor Yellow
(Actually, I think PowerShell is currently implemented a little bit wrong by requiring unnecessary backticks between parentheses. If Microsoft would just follow Python or Tcl parenthesis rules of allowing you to put as many newlines as you want between the starting and ending parenthesis then they would solve most of the problems that people don't like about PowerShell related to line continuation, and concatenation of strings.
I've found that you can leave the backticks off sometimes on line continuations between parenthesis, but it's really flaky and unpredictable if it will work... It's better to just add the backticks.)
Write-host ($assoc.Id.ToString() + " - " + $assoc.Name + " - " + $assoc.Owner)
here $assoc.Id is anInt32
so we have to use its string representation. Otherwise PS tries to perform an arithmetic addition instead of concatenation. – bouvierr