Upload files to "Services Scripts"
This commit is contained in:
@@ -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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user