8 Replies Latest reply on Sep 14, 2017 11:27 AM by xtraspecialj

    How to Start a Windows Service via Alert Action ONLY if the Startup Type is Automatic


      So I'm tasked with setting up an alert in Orion that will Start a Down Windows Service but only if the Startup Type of that Service is set to Automatic.


      I know how to setup a PowerShell script that I can call from the Alert Action and pass the parameters necessary to Start the service.  That isn't my problem.  My problem is how to first query for the Startup Type of that service.  It doesn't look like the standard Windows Component Monitor in SAM captures Startup Type of Services.  I know the Service Control Manager feature does, but I don't know how to tap into that via the API.


      The possible solutions I can think of are as follows:

      - (Least Desired) Create a WMI Script monitor that fetches the startup type of all monitored services on a Windows Node.  I could then query this data for a component via a SWQL query when executing my script.  This would be a total pain, especially considering we have almost a thousand Windows nodes I'd have to apply this to (yeah, I can do it with the new automatic templates assigned to Groups feature, but I really don't want that many more Component Monitors in our environment, we already have SO many.)

      - (Also not Desired) Create a library of possible Windows Credentials in my script and call the appropriate one based on what credential is used by the Component Monitor or Node.  This is not ideal because I don't want to have to store all of my credentials in a script, even if I do encrypt the password.

      - (Most Desired) Somehow call the Credential object from the SWIS API and pass that to my Get-Service cmdlet.  Not sure if this is possible, but that'd be great if it is.

      - (This'll Do) Have my script call the same program that the "Service Control Manager" does in the Orion Web Console and fetch the Startup Type value for the matching service.  Don't know if this is possible either, but this would also be great if it was...



      Can anybody (especially tdanner maybe ) let me know if the bottom two solutions are possible, or maybe if there is another better solution I can't think of?  I really don't want to use my first two options if I can help it.