title: Create a scheduled task with powershell
body: <p>I want to create a scheduled task using a gMSA account via powewershell but I get some errors when I try to register the task. Below you can see my code and the error:</p>
  <pre><code>$action = New-ScheduledTaskAction  &quot;mypath\myscript.ps1&quot;
  $trigger = New-ScheduledTaskTrigger -Weekly -At 12:00 
  $user =  New-ScheduledTaskPrincipal -UserId domain\gmsa -LogonType Password -RunLevel Highest
  Register-ScheduledTask -TaskName &quot;test&quot; -Trigger $trigger -Action $action -User $user
  </code></pre>
  <p>This is the error:</p>
  <pre><code> Register-ScheduledTask : The parameter is incorrect. At line:1 char:1
   + Register-ScheduledTask -TaskName &quot;test&quot; -Trigger $trigger -Action ...
   + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       + CategoryInfo          : InvalidArgument: (PS_ScheduledTask:Root/Microsof     t/...S_ScheduledTask)
   [Register-ScheduledTask], CimException
       + FullyQualifiedErrorId : HRESULT 0x80070057,Register-ScheduledTask
  </code></pre>