locked
Add job trigger RRS feed

  • Question

  • Hello,

    I have created a Scheduled Job using Register-ScheduledJob cmdlet. How can I create an eventlog specific trigger from Powershell?

    New-JobTrigger only accepts triggers based on time interval? From GUI its easy.

    Thanks


    --------------------- Leos

    Friday, March 2, 2018 6:13 AM

Answers

  • Event log triggers are not available in scheduled jobs.  You can use schtasks to define event log tasks.

    PowerShell scheduled jobs are run differently and managed differently.


    \_(ツ)_/

    • Marked as answer by Leoš Marek Friday, March 2, 2018 6:27 PM
    Friday, March 2, 2018 3:49 PM

All replies

  • When I added Event based trigger via GUI, I get this warning from Powershell.

    WARNING: A PSScheduledJob job source adapter threw an exception with the following message: An unknown trigger type was retur
    ned from Task Scheduler for scheduled job definition GC_remove with trigger ID .

    and the job fails. Does this mean what Powershell Scheduled jobs can be only defined based on time triggers?

    thx


    --------------------- Leos

    Friday, March 2, 2018 6:22 AM
  • Exporting an already configured task then importing using powershell might work but I haven't tested it.

    Found this page. 

    http://jon.netdork.net/2011/03/10/powershell-and-importing-xml-scheduled-tasks/

    Friday, March 2, 2018 7:34 AM
  • Im not talking about creating Scheduled Task, but Scheduled Job (powershell). :)

    --------------------- Leos

    Friday, March 2, 2018 8:35 AM
  • Event log triggers are not available in scheduled jobs.  You can use schtasks to define event log tasks.

    PowerShell scheduled jobs are run differently and managed differently.


    \_(ツ)_/

    • Marked as answer by Leoš Marek Friday, March 2, 2018 6:27 PM
    Friday, March 2, 2018 3:49 PM
  • yes I know the difference, just wanted to double-check the trigger topic.

    --------------------- Leos

    Friday, March 2, 2018 6:27 PM