Today I was writing a bit of raw XML to be used as a SOAP message. Being a person who enjoys writing easy to read code, I declared my variable using here-string notation, pasted in the appropriate XML between the @” and “@, making sure to indent everything along the way including the last “@.
Then when I saved my work and tried to run the script, I kept getting an error claiming the “@ terminator was missing. Fast forward a couple minutes of head scratching, checking, double-checking , and triple-checking that there was, indeed, a double-quote followed by an at symbol. Finally I figured it out. The here-string’s “@ terminator needs to be on its own line, with no preceding white-space/tabs/whatever.
And there we have it: my forehead-slapping moment, transformed into a helpful PowerShell quick tip. ๐