Unable to manually run scheduled task after server upgrade from 2012 to 2019

In Windows 2012 (myServer1), I have a scheduled taks (myTask) running as myDomain\user1. I can manually run it any time in addition it runs as scheduled.

After myServer1 was upgraded directly to 2019, myTask still runs successfully as scheduled, but when I run it manually, it failed with error message:
The user account does not have permission to run this task.

I tried the following command to assign permission to user1
$taskPath = ""
$taskName = “myTask”
$principal = New-ScheduledTaskPrincipal -UserId “myDomain\user1” -LogonType ServiceAccount
Set-ScheduledTask -TaskPath $taskPath -TaskName $taskName -Principal $principal

The following command show user1 has READ permission
icacls C:\Windows\System32\Tasks\myTask

C:\Windows\System32\Tasks\myTask myDoamin\user1:(R)
BUILTIN\Administrators:(I)(R,W,D,WDAC,WO)
NT AUTHORITY\SYSTEM:(I)(R,W,D,WDAC,WO)
BUILTIN\Administrators:(I)(F)

But when I manually run it, it still failed with same error.

Please help.
Thanks,

This has nothing with powershell, but I already faced this issue. you can try the following :

  • Export the task to an XML
  • Delete the task
  • Import the task from the XML
1 Like

Yes, export and import works, but I am looking for more efficient way to handle this issue for hundreds of such servers, that’s why I tried to use script and see if feasible.

You can easily export and import with cmd or powershell scripting.