I am trying to get a multi-line variable to write to the event log in its entirety. This is the test strring:
$test = @"
When you echo out $test, it comes out just fine but when it is used in the below command i get an error (both are below). How can I get a multi-line variable (aka Here-String) to write to the event log?
Write-EventLog –LogName "Application" –Source "test" –EntryType "Error" –EventID 1 –Message $test
At C:\Scripts\test.ps1:9 char:112
+ ... â€“EventID 1 â€“Message $test
The string is missing the terminator: ".
+ CategoryInfo : ParserError: (:) , ParseException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString