How to monitor for new evets in eventlog and trigger an action

Arosh Wijepala 161 Reputation points
2022-05-14T14:48:46.827+00:00

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.

Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Limitless Technology 39,926 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--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.