You can use the PowerShell add-content cmdlet to append data to a text file. Here is an example of how to use the add-content PowerShell cmdlet to append text to a file on Windows. We'll also explain the command-line options that you can use.
Powershell add-content example
Step 1. Open PowerShell with elevated privileges
Step 2. Execute the following command, (change the file path)
Add-Content c:\scripts\test.txt "The End"
By default, the data is appended after the last character. If you want to append the data on a new line in the text document, use 'n. There are some other special characters that can be used with the add-content cmdlet.
Here are some other special characters that can be used with the add-content cmdlet.
- `0 -- Null
- `a -- Alert
- `b -- Backspace
- `n -- New line
- `r -- Carriage return
- `t -- Horizontal tab
- `' -- Single quote
- `" -- Double quote