I want to create a (blank) file, and optionally store a text message in it. This is my code for doing so:
$null = new-item "$filename" -type file
write-output ("Message: <<$message>>")
if ( -not ($message= "")) {
Add-Content "$filename" "Message: <$message>"
}
The 1st line creates the file. This works.
The 2nd line visually verifies that I do in fact supply a string (say, the proverbial "hello world").
The 3rd line evaluates to $true and does execute its nested block.
But the 4th line stores a message saying: Message: <>.
I can't figure out the proper syntax for passing the actual value from $message. Help?