I have a manual routine (involving the Scheduled Task GUI) for creating a scheduled task that triggers on a given set of events from the event log. I would like to automate that process using Powershell (alternatively using some other scripting tool) and I have found a small how-to with some examples, as well as the documentation for New-ScheduledTaskTrigger.
Unfortunately, the docs do not show any view of creating a task for some specific event id. It only lists one specific non-time related trigger - -AtLogOn
.
How would I register such a task? Could for instance Get-Eventlog
be used? New-ScheduledTask mentions "trigger objects", but not how to create them and the docs to Triggers are no longer updated and contains no PowerShell relevant info. The docs for New-ScheduledTaskTrigger
seems like exactly what I want:
The New-ScheduledTaskTrigger cmdlet creates and returns a new scheduled task trigger object.
But as I mentioned above, the docs doesn't mention anything about event ids.
powershell
tag is also a hint :-)