The equivalent of rm -rf in Powershell

powershell

As we all know, on a *nix system, rm -rf some_directory removes some_directory and all files beneath it recursively, without asking for confirmation.

What is the equivalent of this command in Powershell?

Note that the answers given here for cmd (using rmdir, etc.) do not work in Powershell. Though Powershell does alias rmdir to Remove-Item (presumably with some switch; not sure which), it doesn't alias cmd-style switches like /s.

Best Answer

This is probably what you're looking for. Seems like a little effort with a search engine would've reached the same conclusion.

Remove-Item C:\MyFolder -Recurse -Force

Or, as a shorthand:

rm <directory-path> -r -f

For more information see the Remove-Item help page.

Related Question