From c43b1120f5b46a7a9b6b58245828076cb116c303 Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Mon, 24 Aug 2026 12:56:06 -0400 Subject: [PATCH] Validate admin site/app-pool exist before attempting to stop them Adds pre-flight checks for AdminSiteName/AdminAppPool at the top of deploy-iis-remote-apply.ps1 (same pattern as the public site), so a wrong name fails fast with a clear error instead of silently skipping the stop and leaving files locked for the wipe. --- scripts/deploy-iis-remote-apply.ps1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/deploy-iis-remote-apply.ps1 b/scripts/deploy-iis-remote-apply.ps1 index 74d9c6f..db6d223 100644 --- a/scripts/deploy-iis-remote-apply.ps1 +++ b/scripts/deploy-iis-remote-apply.ps1 @@ -78,6 +78,14 @@ if(!(Get-Website -Name $SiteName -ErrorAction SilentlyContinue)){ if(!(Test-Path ('IIS:\AppPools\' + $AppPool))){ throw "App pool '$AppPool' does not exist yet. Create it once manually before running this deploy." } +if(![string]::IsNullOrWhiteSpace($AdminSiteName)){ + if(!(Get-Website -Name $AdminSiteName -ErrorAction SilentlyContinue)){ + throw "IIS admin site '$AdminSiteName' does not exist yet. Create the site and app pool once manually before running this deploy." + } + if(![string]::IsNullOrWhiteSpace($AdminAppPool) -and !(Test-Path ('IIS:\AppPools\' + $AdminAppPool))){ + throw "Admin app pool '$AdminAppPool' does not exist yet. Create it once manually before running this deploy." + } +} Write-Host "Stopping IIS site $SiteName and app pool $AppPool" try { Stop-Website -Name $SiteName } catch { } @@ -134,9 +142,6 @@ Set-ItemProperty ('IIS:\AppPools\' + $AppPool) -Name enable32BitAppOnWin64 -Valu # --- Admin site --- $adminPublicDir = Join-Path $RemoteDir 'public-admin' if(![string]::IsNullOrWhiteSpace($AdminSiteName) -and (Test-Path $adminPublicDir)){ - if(!(Get-Website -Name $AdminSiteName -ErrorAction SilentlyContinue)){ - throw "IIS admin site '$AdminSiteName' does not exist yet. Create the site and app pool once manually before running this deploy." - } Write-Host "Configuring admin site $AdminSiteName" if(![string]::IsNullOrWhiteSpace($AdminAppPool)){ Set-ItemProperty ('IIS:\Sites\' + $AdminSiteName) -Name applicationPool -Value $AdminAppPool