title: Powershell script to schedule daily task error
body: <p>I have a very simple power shell script that will register console applications as daily scheduled tasks.</p>
  <pre><code>$TaskCommand = Read-Host 'Enter the path to the console application'
  $TaskName = &quot;TaskName&quot;
  $TaskStartTime = &quot;10PM&quot;
  $TaskArg = &quot;-WindowStyle Hidden -NonInteractive -Executionpolicy unrestricted&quot;
  
  $TaskAction = New-ScheduledTaskAction -Execute &quot;$TaskCommand&quot; -Argument &quot;$TaskArg&quot;
  $TaskTrigger = New-ScheduledTaskTrigger -At $TaskStartTime -Daily
  Register-ScheduledTask -Action $TaskAction -Trigger $TaskTrigger -TaskName &quot;$TaskName&quot; -User %computername%\theusername -Password &quot;password&quot; -RunLevel Highest
  </code></pre>
  <p>The application reads the file path from user input and attempts to register the application as a task using a specific user account. I can get the script working by using</p>
  <pre><code>-User &quot;System&quot;
  </code></pre>
  <p>However when I try to use the above script I get this error:</p>
  <blockquote>
  <p>Register-ScheduledTask: No mapping between account names and security IDs was done.</p>
  </blockquote>
  <p>I have ensured that the account exists as it is currently running several services. I am also new to powershell so have tried adding quotations around the username with no luck.</p>