Closed jordigg closed 6 years ago
Now I saw #130 with the same problem. I see that it's because the indentation.
I have that code inside an if
condition and that's why I use the indentation but it's still located at the same level as the opening @
.
Without identation
$var = @"
Long text inside a variable
Long text inside a variable 2
Long text inside a variable 3
Long text inside a variable 4
"@
New-Item -path C:\temp -name bla.conf -type "file" -value $var -force
With identation
if($bla){
$var = @"
Long text inside a variable
Long text inside a variable 2
Long text inside a variable 3
Long text inside a variable 4
"@
New-Item -path C:\temp -name bla.conf -type "file" -value $var -force
}
Seems that Github have the same problem or I'm doing something wrong. How should I write that "Here-Strings" variable? At the top of my script outside any indentation?
That's not a bug, that's a feature.
Here strings in PowerShell have 3 character delimiters: at, quote, newline ---> newline, quote, at.
If there's whitespace between the newline and the quote, it's not valid powershell.
Yes, thank you @Jaykul ! The indentation makes it invalid here-string.
When using
breaks syntax highlighting. Removing the first
@
fixes the highlight so I guess the error is how that @ is parsed.Here a screen-shoot, with and without the first
@