I want to write a powershell script that get executed whenever a new item/eventlog entry in the eventlog 'Microsoft-Windows-TerminalServices-Gateway/Operational' gets written.

It is easy to create a scheduler task that triggers whenever a new eventlog item gets created and that then execute a powershell script.

Now my question is, inside that powershell script, how can I access the eventlog-item that has triggered the trigger?

1 Answer 1


OK, found some info. Seems you need to hack the task definition to let it pass over the values as variables to the called script.


see: https://michlstechblog.info/blog/windows-passing-parameters-to-event-triggered-schedule-tasks/ https://cloudrobots.net/2014/08/24/trigger-a-powershell-script-from-a-windows-event/ https://community.spiceworks.com/how_to/123434-run-powershell-script-on-windows-event

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .