i have powershell script that check if the service is up and of not it starts it up,
$ServiceName = 'mapguideserver3.1'
$arrService = Get-Service -Name $ServiceName
while ($arrService.Status -ne 'Running')
{
Start-Service $ServiceName
write-host $arrService.status
write-host 'Service starting'
Start-Sleep -seconds 60
$arrService.Refresh()
if ($arrService.Status -eq 'Running')
{
Write-Host 'Service is now Running'
}
}
i tried to use it in a task scheduler as system startup and right click and run , by setting "allow it to run on demand"
i saw that the task status is "running" and after some time it changes to "ready", when i checked after some time the task doesn't changes back the service if its stopped.
how can i run the script that it will run forever?