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

$ErrorActionPreference = "Stop"

Write-Output "Deleting IIS Websites and AppPools started..."

$sitecoreSite = $SAFConfiguration.sitecore.hostNames[0]
$xConnectSite = $SAFConfiguration.xConnect.hostName
$identityServerSite = $SAFConfiguration.identityServer.hostName
$sites = @("$sitecoreSite", "$xConnectSite", "$identityServerSite")

foreach ($site in $sites) {
    if ([string]::IsNullOrEmpty($site)) { continue }
    DeleteIISWebsite -SiteName $site
    DeleteIISAppPool -AppPoolName $site
}

Write-Output "Deleting IIS Websites and AppPools done."