title: PowerShell - Create Scheduled Task with Password argument securely?
body: <p>The below code creates the scheduled task with the proper parameters, but how can I hide/encrypt the password in a way that it's secure and functional? I am encrypting the password with PS, but I'm having to decrypt it so I can pass it as an argument. Is there an alternative (secure) way to schedule a task that launches an exe with a password argument using PowerShell?</p>
  <pre><code>        $action = New-ScheduledTaskAction -Execute $Fullpath -Argument &quot;--serverURL $TestServer --userName $TestUser --password $TestPassword&quot;
          
          $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddSeconds(2)
          
          $principal = New-ScheduledTaskPrincipal -UserID &quot;NT AUTHORITY\SYSTEM&quot; -LogonType ServiceAccount -RunLevel Highest
          
          $settings = New-ScheduledTaskSettingsSet -MultipleInstances Parallel
          
          Register-ScheduledTask -Action $action -Trigger $trigger -TaskName &quot;Task&quot; -Description &quot;Scheduled Task&quot; -Principal $principal -Settings $settings
          
  </code></pre>