PowerShell: Remove a Folder

Need to delete a folder - cleaning up a temp directory, removing a leftover from a script, or tearing down a test setup? This one-liner removes it directly from the terminal.

Prerequisites:

  • Privileges: None
  • Module: Built-in, no import needed

Quick Command:

Remove-Item -Path "C:\NewFolder"
📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.

How It Works:

  • Remove-Item deletes the item at the specified path - it works on files and folders alike.
  • -Path "C:\NewFolder" points to the folder you want to delete - replace this with whatever path you actually want to remove.
  • If the folder contains files or subfolders, this fails by default and asks for confirmation.

Pro Tip:

To delete a folder along with all its contents in one go, without confirmation prompts:

Remove-Item -Path "C:\NewFolder" -Recurse -Force