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-678f4d155b928558230225/]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-678f4d155b930477706359/]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-678f4d155b932583535407/]OUTPUT: