A WMI event consumer will do that. use-powershell-to-monitor-and-respond-to-events-on-your-server
How to monitor for new evets in eventlog and trigger an action
I would like to know the logic or the piece of powershell code that can be used to monitor for a service shutdown event and trigger an action. So when the service stopped, event is written to the eventlog. Powershell should detect that and trigger the action. But this service start/stop actions can be several at a given time. So I want to run the powershell script every 5 minutes, detect whether there is a service shutdown event within that time frame and trigger an action. How can I achieve this? Any help would be greatly appreciated.
Thanks.
1 additional answer
Sort by: Most helpful
-
Limitless Technology 39,356 Reputation points
2022-05-23T08:35:57.457+00:00 Hello
Thank you for your question and reaching out. I can understand you are having query related to Actions while Windows Events occurred.
Scheduled Tasks should get invoked whenever the event Trigger conditions are met.
Depending on the Action that is being executed (e.g. Start a program) that may run continually until the process / application is terminated. Event based Triggers should be able to run from startup and before logon.
--If the reply is helpful, please Upvote and Accept as answer--