$PushUrl = "https://uptime.twe.tech/api/push/LD1QrYEisE2n0xlWuB8w3bqLsKDqly2a?status=up&msg=OK&ping=" $ScriptPath = "C:\ProgramData\KumaPushAgent.ps1" # 1. Create the looping PowerShell script $ScriptBody = @" while (`$true) { try { Invoke-RestMethod -Uri '$PushUrl' -ErrorAction SilentlyContinue } catch {} Start-Sleep -Seconds 20 } "@ Set-Content -Path $ScriptPath -Value $ScriptBody # 2. Configure the Scheduled Task $Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-WindowStyle Hidden -ExecutionPolicy Bypass -File `"$ScriptPath`"" $Trigger = New-ScheduledTaskTrigger -AtStartup $Principal = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest $Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit ([TimeSpan]::Zero) # 3. Register and start the task Register-ScheduledTask -TaskName "UptimeKuma-PushAgent" -Action $Action -Trigger $Trigger -Principal $Principal -Settings $Settings -Force Start-ScheduledTask -TaskName "UptimeKuma-PushAgent" Write-Host "Success! The Push Agent is installed, running in the background, and will survive reboots without a login." -ForegroundColor Green -------------------------------------------------------------------------------------------- if Mistakes Happens in the script: Quick Verification Commands If you ever want to check the status or stop the agent, you can use these: Check status: Get-ScheduledTask -TaskName "UptimeKuma-PushAgent" Stop the agent: Stop-ScheduledTask -TaskName "UptimeKuma-PushAgent" Remove the agent: Unregister-ScheduledTask -TaskName "UptimeKuma-PushAgent" -Confirm:$false