If that doesn't work, follow these steps:
# In a NEW PowerShell window (Run as Administrator):
# Find PowerShell processes
Get-Process powershell* | Select-Object Id, ProcessName, StartTime, CPU
# Kill the specific PowerShell process running the script
# Replace <PID> with the Process ID from above
Stop-Process -Id <PID> -Force
# OR kill all PowerShell processes (WARNING: closes all PowerShell windows)
Get-Process powershell* | Stop-Process -Force# Remove the guard variable
Remove-Variable -Name DeployApiServerRunning -Scope Global -ErrorAction SilentlyContinue# Check if app pool and website exist and their states
Get-WebAppPool "SecureBootDashboard.Api" -ErrorAction SilentlyContinue
Get-Website "SecureBootDashboard.Api" -ErrorAction SilentlyContinue
# Stop them if needed
Stop-WebAppPool "SecureBootDashboard.Api" -ErrorAction SilentlyContinue
Stop-Website "SecureBootDashboard.Api" -ErrorAction SilentlyContinueThe infinite loop might be caused by:
Check if your PowerShell profile is executing the script:
# Check profile path
$PROFILE
# View profile contents
Get-Content $PROFILE -ErrorAction SilentlyContinue
# Temporarily rename profile to disable
Rename-Item $PROFILE "$PROFILE.backup" -ErrorAction SilentlyContinueCheck if the script is being run by a scheduled task:
Get-ScheduledTask | Where-Object {$_.Actions.Execute -like "*Deploy-ApiServer*"}Check if any file watcher or deployment tool is triggering the script.
The Start-WebAppPool cmdlet might be configured to run a script on start.
Check application pool settings:
# In IIS Manager:
# Application Pools ? SecureBootDashboard.Api ? Advanced Settings
# Check "Start Mode" and any startup scriptsBefore running the script again:
-
Verify you have the latest version with guards:
# Check for guard variable at top of script Get-Content scripts\Deploy-ApiServer.ps1 -Head 70 | Select-String "DeployApiServerRunning"
-
Run with verbose output to see where it loops:
$VerbosePreference = "Continue" .\scripts\Deploy-ApiServer.ps1 -Verbose
-
Use WhatIf mode first:
.\scripts\Deploy-ApiServer.ps1 -WhatIf
# Check current call stack
Get-PSCallStack
# Check if script is in a loop
$Error[0] | Format-List * -Force
# Check event logs for clues
Get-EventLog -LogName Application -Newest 50 |
Where-Object {$_.Message -like "*Deploy-ApiServer*"}If the script continues to fail, configure manually:
- Open IIS Manager
- Create Application Pool:
- Name: SecureBootDashboard.Api
- .NET CLR Version: No Managed Code
- Identity: ApplicationPoolIdentity
- Create Website:
- Name: SecureBootDashboard.Api
- Physical Path: C:\inetpub\SecureBootDashboard.Api
- Binding: https, port 443, hostname api.yourdomain.com
- App Pool: SecureBootDashboard.Api
- Bind SSL Certificate:
- Right-click website ? Edit Bindings
- Select HTTPS binding ? Edit
- Choose your SSL certificate
- Start Application Pool and Website
If issue persists:
- Check
$Error[0]for detailed error - Review all output carefully for patterns
- Check if script is somehow calling itself
- Consider debugging with:
Set-PSDebug -Trace 2
Ensure you have the latest fixed version:
- Should have
$global:DeployApiServerRunningguard at top - Should have
$script:WebSiteStartAttemptedguard in Start-WebSite function - Version should be 1.2 or higher