Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

Using the Set-Content Cmdlet

Saving Data to a Text File

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:

Set-Content c:\scripts\test.txt "This is a test"

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.

Set-Content Aliases
  • sc

Related Links

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft