How to quietly remove a directory with content in PowerShell How to quietly remove a directory with content in PowerShell powershell powershell

How to quietly remove a directory with content in PowerShell


Remove-Item -LiteralPath "foldertodelete" -Force -Recurse


From PowerShell remove force answer: help Remove-Item says:

The Recurse parameter in this cmdlet does not work properly

The command to workaround is

Get-ChildItem -Path $Destination -Recurse | Remove-Item -force -recurse

And then delete the folder itself

Remove-Item $Destination -Force 


This worked for me:

Remove-Item $folderPath -Force  -Recurse -ErrorAction SilentlyContinue

Thus the folder is removed with all files in there and it is not producing error if folder path doesn't exists.