Force Deletion Using PowerShell

Ray Turner
Ray Turner used Ask the Experts™
How do I delete a specific sub-folder in C:\Program Files (x86) using Windows PowerShell?  I want to delete the sub-folder and ALL of the child folders/files.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
1. you must run powershell as an administrator
2  remove-item -path "c:\program files (x86)\whatever -recurse -force"
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

The double quotes need to enclose the path:
remove-item 'c:\program files (x86)\whatever' -recurse -force

Open in new window

I've also changed to ticks to prevent PowerShell from trying to accidentally detect an expression in the string.
Ray TurnerSenior Consultant


Thanks a lot!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial