Scheduling tasks inside windows server core 2016 docker

I’m trying to create a cron job using Task Scheduler on a windows server core (2016) docker, but I’m running into an error. It doesn’t look like there is any literature regarding this issue on the web. Has anybody come across the below mentioned error?

Expected behavior

This is excerpt from my windows 2016 server m/c

PS C:\WINDOWS\system32> $trigger = New-JobTrigger -once -At $(get-date) -RepetitionInterval $([timespan]::FromMinutes(‘1’)) -RepeatIndefinitely
PS C:\WINDOWS\system32> Register-ScheduledJob -Name CopyToS35 -ScriptBlock { echo “hi”; } -Trigger $trigger

Id Name JobTriggers Command Enabled


1 CopyToS35 1 echo “hi”; True

Actual behavior

This is excerpt from my windowsservercore docker (latest)
PS C:> $trigger = New-JobTrigger -once -At $(get-date) -RepetitionInterval $([timespan]::FromMinutes(‘1’)) -RepeatIndefinitely
PS C:> Register-ScheduledJob -Name CopyToS35 -ScriptBlock { echo “hi”; } -Trigger $trigger
Register-ScheduledJob : An error occurred while registering scheduled job definition CopyToS35 to the Windows Task Scheduler. The Task Scheduler error is: (42,4):Task:.
At line:1 char:1

  • Register-ScheduledJob -Name CopyToS35 -ScriptBlock { echo “hi”; } -Tr …
  •   + CategoryInfo          : InvalidOperation: (Microsoft.Power...edJobDefinition:ScheduledJobDefinition) [Register-ScheduledJob], ScheduledJobException
      + FullyQualifiedErrorId : CantRegisterScheduledJobDefinition,Microsoft.PowerShell.ScheduledJob.RegisterScheduledJobCommand
    
    

Information

docker : microsoft/windowsservercore
Invocation : docker run -it microsoft/windowsservercore powershell

Steps to reproduce the behavior

Fire the aforementioned commands to create the scheduled task, and see the task scheduling command fail with the same error.

Hello,

I have the same behavior (same error type) with the CommandLine following inside Container Windows !

Thank you very much for your support.
David