Hello,
I have developed a script to detect a service stop event by attaching a scheduled task to the eventlog, event ID 7036 and to run a Powershell script upon detecting event id 7036. However, I later realized that event id is not unique to this service and it's written to eventlog by service control manager for every service that is getting started or stopped (not only service stopped event)
For this reason, the script misses execution if the service is quick to get stopped and get started back up again. Also it's getting missed as there are several service restarts by several applications written to the event log at a given time.
Anyone can help me with the logic to detect this kind of a service restart? I am looking to monitor SQL Server service restarts.
Thanks in advance.