Folder cleanup with PowerShell
Posted
by 280Z28
on Stack Overflow
See other posts from Stack Overflow
or by 280Z28
Published on 2010-04-24T14:12:52Z
Indexed on
2010/04/24
14:13 UTC
Read the original article
Hit count: 286
powershell
|powershell-v2.0
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.
© Stack Overflow or respective owner