How to Append Data to a Text File Using PowerShell

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.

1

Add-Content"C:\dotnet-helpers\DummyfiletoDelete.txt""This is the last line"

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.