title: Register scheduled task with New-ScheduledTaskTrigger to trigger on event ID
body: <p><strong>Register-ScheduledTask with New-ScheduledTaskTrigger on a Windows event ID</strong>  </p>
  
  <p>Hello Stack-overflow users. Neither MSDN nor Google yields results...<br>
  I configured a couple of scheduled tasks via a Powershell script. The scheduled tasks are set to run at certain times.<br>
  This all works fine. But I need to configure another scheduled task which run when a certain event ID is logged in the Windows event logger.<br>
  I can set this up manually of course but I want it as part of my automated script.  </p>
  
  <p>this is the code I have so far for the scheduled tasks, I need to replace the <em>$Trigger= New-ScheduledTaskTrigger -At 4:00am -Daily</em> section:  </p>
  
  <pre class="lang-bsh prettyprint-override"><code>        Copy-Item "\\networkDrive\Backups\scripts\Reset-Sessions.ps1" "c:\scripts\Reset-Sessions.ps1"
          $Trigger= New-ScheduledTaskTrigger -At 4:00am -Daily
          $User= 'Nt Authority\System'
          $Action= New-ScheduledTaskAction -Execute "Powershell.exe" -Argument "-executionpolicy bypass -File c:\scripts\Reset-Sessions.ps1"
          Register-ScheduledTask -TaskName "Reset-Sessions" -Trigger $Trigger -User $User -Action $Action -RunLevel Highest -Force
  </code></pre>
  
  <p>I have changed some of the directory and file names for online purposes.  </p>
  
  <p>I would appreciate it if somebody could steer me into the right direction or assist with an example.<br>
  I would prefer to only change the $Trigger portion and not re-write the whole script but I would understand if it is not possible.  </p>
  
  <p>I use Powershell version 5.1.  </p>