Task Scheduler “On disconnect from user session” trigger not working

task-schedulerwindows-server-2012-r2windows-server-2016

Using Win Server 2012 R2 test machine (not in domain) I was able to get it triggering with the setup:

  • General:

    • When running the task, use the following user account: built in admin account
    • Run whether user is logged on or not: checked (do not store password not checked)
    • Run with highest privileges: checked
  • Triggers:

    • On disconnect from user session (Any user, Connection from remote computer and Enabled all checked)
  • Actions:

    • Start a program: Powershell (Add arguments: -ExecutionPolicy Bypass -File "C:\Scripts\Awesome_Script.ps1"; Start In: C:\Scripts)
  • Conditions:

    • Nothing checked
  • Settings:

    • Allow the task to be run on demand: checked
    • Stop if the task runs longer than: 1 hour
    • If the running task does not end when requested, force it to stop: checked

When I copied everything over (same location and imported the task) to Win Server 2016 test machine (in domain) then the same setup fails to trigger. No errors in History and "Last Run Result" tells me that The task has not yet run.

And of course I updated the “When running the task, use the following user account” to the Server 2016 local admin account. I tried also to run it from Admin group, SYSTEM account, my own (admin) account but nothing helped (these failed also on the 2012 R2).

Does anyone have any ideas why the trigger fails on the Server 2016 (in domain) while the only thing that changed is the Account? What am I missing here?

Best Answer

Update: We saw positive results after 24 hours passing after the rules creation and activation. Not sure why and if there were contributing factors (i.e. restarts, gpupdates etc.) so I'm hesitant to call it resolved but hopefully this info can help someone else too.