Saving Data to a Text File

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

The primary use of Set-Content is to write data to a text file. For example, this command writes the text “This is a test” to the text file C:\Scripts\Test.txt:


Note that this replaces the existing contents of Test.txt with the new text specified in the command. To append text to a file, use the Add-Content cmdlet.