Pipelines/Steps/Install/OnPrem/Sitecore/Uninstall/Delete-Folders.ps1

$ErrorActionPreference = "Stop"

$sitecoreRootDir = $SAFConfiguration.sitecore.installDir
$xConnectRootDir = $SAFConfiguration.xConnect.installDir
$identityServerRootDir = $SAFConfiguration.identityServer.installDir

Write-Output "Deleting folders started..."

$dirs = @("$sitecoreRootDir", "$xConnectRootDir", "$identityServerRootDir")
foreach ($dir in $dirs) {
    if ([string]::IsNullOrEmpty($dir)) { continue }
    if (Test-Path $dir) {
        Write-Output "Deleting '$dir'..."
        Remove-Item $dir -Recurse -Force | Out-Null
    }
    else {
        Write-Output "'$dir' doesn't exist..."
    }
}

Write-Output "Deleting folders done."