From 0fbb889dfc9a9a0ecb2d0f2e250e37740bc5ffa7 Mon Sep 17 00:00:00 2001 From: Gabe Date: Tue, 5 Aug 2025 16:07:55 +0000 Subject: [PATCH] Upload files to "Services Scripts" --- Services Scripts/auto start agent service.ps1 | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Services Scripts/auto start agent service.ps1 diff --git a/Services Scripts/auto start agent service.ps1 b/Services Scripts/auto start agent service.ps1 new file mode 100644 index 0000000..60ecb5b --- /dev/null +++ b/Services Scripts/auto start agent service.ps1 @@ -0,0 +1,27 @@ +$serviceName = "Windows Agent Maintenance Service" + +$arrService = Get-Service -Name $serviceName + +while ($arrService.Status -eq 'Running') { + Write-Host $serviceName $arrService.status + Start-Service $serviceName + Write-Host $serviceName $arrService.status + + # Wait a short period before checking the service + Start-Sleep -seconds 5 + + $arrService.Refresh() + Write-Host $serviceName $arrService.status + + + if ($arrService.Status -eq 'Running') { Continue } + # Attempt to restart service + Start-Service $serviceName + Write-Host $serviceName $arrService.status + + # Wait a short period before checking the service + Start-Sleep -seconds 10 + + $arrService.Refresh() + Write-Host $serviceName $arrService.status +} \ No newline at end of file