Folder cleanup with PowerShell
- by 280Z28
I'd like to clean up some directories after my script runs by deleting certain folders and files from the current directory if they exist. Originally, I structured the script like this:
if (Test-Path Folder1) {
Remove-Item -r Folder1
}
if (Test-Path Folder2) {
Remove-Item -r Folder2
}
if (Test-Path File1) {
Remove-Item File1
}
Now that I have quite a few items listed in this section, I'd like to clean it up. How can I do so?
Side note: The items are cleaned up before the script runs, since they are left over from the previous run in case I need to examine them.