Hello,
I want to get service state, and if the service is not started then start it, and repeat the process until it really starts (it may fail sometimes).
I tried the following :
$svc = Get-Service Service_Name
while ($svc.Status -eq "Stopped") {Start-Service $svc.name}
But here $svc remains static, then it won't exit the while loop even is service is started.
So I tried this in order to query the service at each occurence of loop:
while ((get-service Service_Name | $_.Status) -eq "Stopped") {Start-service Service_Name}
But I get syntax error.
What is the correct syntax ?
Thanks for your help !
Regards
Julien