Refresh when needed to renew the properties to current values. Status is a static property, corresponding to the value at the time of the call. Why is that third last line required? I think you may have over-complicated your code: If you are just checking to see if a service is running and, if not, run it and then stop re-evaluating, the following should suffice. PowerShell Pro Tools - Create a Windows Service with PowerShell I can check in the Windows service manager and the service was clearly started after the first loop. If I run the code without the third last line the one with the commentI get the following output. I have found the loop does not behave the way I expected in that I seem to have to re-assign the service variable within the loop in order to get the updated status. Keep repeating this process until the service start successfully. If it is not started, try to start it then wait one minute and check again. ![]() ![]() I have built a small powershell script to check if a service is started. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Monitor a web app with web server logsĬhange your preferences any time. By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |