Ah, and if you have a very long string that you want to break up, say of HTML, you can do it by putting a @
on each side of the outer "
- like this:
$mystring = @"
Bob
went
to town
to buy
a fat
pig.
"@
You get exactly this:
Bob
went
to town
to buy
a fat
pig.
And if you are using Notepad++, it will even highlight correctly as a string block.
Now, if you wanted that string to contain double quotes, too, just add them in, like this:
$myvar = "Site"
$mystring = @"
<a href="http://somewhere.com/somelocation">
Bob's $myvar
</a>
"@
You would get exactly this:
<a href="http://somewhere.com/somelocation">
Bob's Site
</a>
However, if you use double-quotes in that @-string like that, Notepad++ doesn't realize that and will switch out the syntax colouring as if it were not quoted or quoted, depending on the case.
And what's better is this: anywhere you insert a $variable, it DOES get interpreted! (If you need the dollar sign in the text, you escape it with a tick mark like this: ``$not-a-variable`.)
NOTICE! If you don't put the final "@
at the very start of the line, it will fail. It took me an hour to figure out that I could not indent that in my code!
Here is MSDN on the subject: Using Windows PowerShell “Here-Strings”