'PowerShell Delete folder if exists

Could you help me again with a powershell script? I want to check if multiple folders exist, if they exist then delete the complete folder. Also provide information if the folder has been deleted or information if the folder does not exist.

I now use the script below for multiple files. (thanks to good help) I want to use the same script for 1 or more folders. For example, delete folder c:\test1\ and c:test2
Folders may be deleted, even if they still contain files.

$paths =  "c:\test\1.txt", "c:\test\2.txt", "c:\test\3.txt"
foreach($filePath in $paths)
{
    if (Test-Path $filePath) {
        Remove-Item $filePath -verbose
    } else {
        Write-Host "Path doesn't exits"
    }
}

I'm not super handy with powershell, hope you can help me with this again.

Thanks Tom



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source