Task scheuduler with gmsa error: 0x80070057 RRS feed

  • Question

  • Hi!

    I had a problem with register-scheuduled task when i run my script i allways got the following error: FullyQualifiedErrorId : HRESULT 0x80070057,Register-ScheduledTask

    my environment:

    Win server 2016

    gmsa account who had the right to run scripts in scheudule

    psVersion: 5.1

    My script:

    $task_name = "TestTask"
    $task_name2 = "NewTask"
    $principal = New-Scheduledtaskprincipal -userid domain\gmsa$ -logontype Password
    $tasktocopy = Get-ScheduledTask $TestTask
    $action = $tasktocopy.Actions
    $trigger = $tasktocopy.Triggers
    Register-ScheduledTask -TaskPath \Microsoft\ -taskname $task_name2 -Action $action -Trigger $trigger -Principal $principal

    Test task: 

    i create a dummy task in GUI where i set 2 parameter: 

    1: trigger: mountly, (run in all mounts on day 1 and 16)

    2: Action: Start a program , Program/script: c:\test\test.cmd


    Register-ScheduledTask : The parameter is incorrect.
    At line:9 char:1
    + Register-ScheduledTask -TaskPath \ -taskname $task_name2 -Action $act ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [Register-ScheduledTask], CimException
        + FullyQualifiedErrorId : HRESULT 0x80070057,Register-ScheduledTask

    I read on forums it could be the task name what is cached

    In registry i didnt see my test tasks neither in C:\Windows\System32\Tasks\Microsoft

    I already try name it differently but the same error is occured

    Thank you

    • Edited by V9988 Thursday, April 4, 2019 8:38 AM
    • Moved by Bill_Stewart Wednesday, September 4, 2019 7:50 PM This is not scheduler troubleshooting forum
    Thursday, April 4, 2019 7:58 AM