Add-Content
Append text to a file
Add-Content -Path .\notes.txt -Value 'Another line'
- Works on
- WindowsLinuxmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: Add-Content
Appends without deleting existing lines. Creates the file if it does not exist.
Try this
Add-Content -Path .\notes.txt -Value (Get-Date)
Coming from another shell
| Shell | What you might type |
|---|---|
| bash / zsh | echo 'Another line' >> notes.txt |
| cmd.exe | echo Another line>> notes.txt |
More in From bash and From cmd.