Set-Content

noun

say it: “SET KON-tent” /ˈsɛt ˈkɑntɛnt/

A PowerShell command that writes text into a file, making the file if it's new and replacing everything in it if it isn't.

What does Set-Content do?

Set-Content writes text into a file. A new file is made; a file that's already there is wiped and written fresh, so everything it held is replaced. Give it several values, with commas, for several lines. To keep what's there and add to the end, use Add-Content.

Set-Content todo.txt 'TO DO', '- unpack', '- find the remote'

In a sentence

  • “Set-Content wiped the old list, so only the new lines were left.”
  • “Sam started a fresh to-do list with Set-Content, three lines at once.”

Level: Novice · More PowerShell terms at this level

Updated