Skip to main content

Add Information to the End of a File in Windows PowerShell

Problem

You want to redirect the output of a pipeline into a file but add the information to the end of that file.

Solution

To redirect the output of a command into a file, use either the Append parameter of the OutFile cmdlet, or one of the appending redirection operators. Both support options to append text to the end of a file.

OutFile:

GetChildItem | OutFile Append files.txt

Redirection operators:

GetChildItem >> files.txt

Discussion

The OutFile cmdlet and redirection operators share a lot in common—and for the most part, you can use either. 

Manage files efficiently with PowerShell on a United Kingdom Dedicated Server, offering reliable performance, dedicated resources, and complete server control.

Help Category