title: Run Powershell script in windows Task Scheduler(Windows 7)
body: <p>Hi I've got a Script and are trying to start it in Task Scheduler.</p>
  
  <p>this poses Two problems for me. </p>
  
  <ol>
  <li>
  is that the script will activate a Application that requires the GUI to be running and shown. so how can I make Task Scheduler to log in to windows automatically at a specific time. The computer will never/rarely be turned off or rebooted.</li>
  </ol>
  
  <p>2.
  I have yet to Successfully start a Powershell script from the Task Scheduler. I've tried Following:</p>
  
  <pre><code>powershell.exe -noexit -executionpolicy bypass -command &amp;'Y:\Run Test\StartPowershellScript.ps1'
  </code></pre>
  
  <p>And</p>
  
  <pre><code> powershell.exe -noexit -ExecutionPolicy Bypass -File 'Y:\Run Test\StartPowershellScript.ps1'
  </code></pre>
  
  <p>And a variation of the above.</p>
  
  <pre><code>powershell.exe -noexit -ExecutionPolicy Bypass &amp;'Y:\Run Test\StartPowershellScript.ps1'
  </code></pre>
  
  <p>and I've tried some variations with and without &amp;"" &amp;'' &amp; and so on. </p>
  
  <p>now I'm not really sure if it can be done. but I hope I can get some help here. </p>
  
  <p><strong>Edit 1.</strong>
  I just tried the following. </p>
  
  <pre><code>powershell -noexit -ExecutionPolicy Bypass &amp;'Y:\Run Test\StartPowershellScript.ps1'
  </code></pre>
  
  <p>after I did this in powershell.</p>
  
  <pre><code>set-executionpolicy -scope Process -executionPolicy Unrestricted -force
  set-executionpolicy -scope CurrentUser -executionPolicy Unrestricted -force
  set-executionpolicy -scope LocalMachine -executionPolicy Unrestricted -force
  </code></pre>
  
  <p>However How do I make sure that this will persist after the computer has been rebooted ? </p>
  
  <p><strong>Edit 2.</strong>
  as it seems I can't make Scheduled task log in or unlock the computer, is there Anyway to set up a task to run at a specific time to log in to the computer so the scheduled task can run at this time ? </p>