Here’s we can discuss on how to add text to the end of a text file using the Add-Content cmdlet using PowerShell.  In our example let’s add “This is the last line” to the end of a file using add-content cmdlet to append data to a text file.

[crayon-67b9771ac1654249577096/]

The above example above adds the text to the last line of the text, it doesn’t actually create a new line. We can use an escape character to tell PowerShell to add a carriage return, new line… while appending the text in existing file.

Escape characters:

‘n — New line
‘t — Horizontal tab
‘’ — Single quote
‘” — Double quote
‘0 — Null
‘a — Alert
‘b — Backspace
‘r — Carriage return

Append Text using Escape characters:

[crayon-67b9771ac165b423059656/]

The above example append the “This is the last line” as a new line at end of the text file with help of ‘n and’ r

[crayon-67b9771ac165e261520310/]  

 OUTPUT: