I need to have a batch file or powershell script that will search a given directory when ran and delete any folders (and their files) that are inside that directory.
For Example: I am trying to delete folder called 'AppStore' that is located at C:\Users\Jeff\ AND also located at C:\Users\Jim AND c:\Users\Bob . So, I need to be able to delete the folder and corresponding files associated with the directorty in any folder under C:Users\ .
Thanks.
I have tried to write a batch file but I can only get it to delete the folders IF I know the exact path. And being as I would run this on multiple machines the path would change.
Using PowerShell and its
Remove-Itemcmdlet (as noted, you'll need to run with elevation):Note: The
-WhatIfcommon parameter in the command above previews the operation. Remove-WhatIfand re-execute once you're sure the operation will do what you want.