The TechNet article seems straightforward - use Add-Content <filename> and put `n at the end of your string to add an extra line. (http://technet.microsoft.com/en-us/library/ee156791.aspx)
I've tried appending the newline character to my output string
$string = "My Output Text`n"
Add-Content c:\myfile.txt $string
this results in My Output Text`n appearing on a single line in my output file
I tried setting a variable to equal "`n"
$blankLine = "`n"
Add-Content c:\myfile.txt $blankLine
This results in the script halting and prompting:
cmdlet Add-Content at command pipeline position 1
Supply values for the following parameters:
Value[0]:
I've tried just passing the newline character as a literal
add-content c:\myfile.txt "`n"
cmdlet Add-Content at command pipeline position 1
Supply values for the following parameters:
Value[0]:
I've also tried using "`r`n" using the methods above (instead of just "`n") with the same results.
Now for the crazy part. If I do everything from the PowerShell commandline, e.g., Add-Content c:\myfile.txt "`r`n`r`n`r`n", the cmdlet puts three blank lines in the output file, no questions asked. BTW-if I used "`n`n`n" I got only one blank line in my output file.
All I want to do is write a blank line to the output file from my script, so maybe Add-Content is the wrong cmdlet. What am I doing wrong? This is driving me crazy!