title: Scheduled Powershell task not being executed
body: <p>I added a powershell script task on the Task Scheduler, set the user account to an Admin, then set the option to "Run only when user is logged on".</p>
  
  <p>When I run this task manually, it executes correctly, but when I set the option to "Run whether user is logged on or not" it executes but never completes the task successfully.</p>
  
  <p>"Run with highest privileges" is enabled on both scenario. What seems to be happening? How do I run the task without needing to be logged on?</p>
  
  <p>EDIT:</p>
  
  <p>Script copies file from a mounted drive to a local directory. When I run the script line by line using Powershell instead of the task scheduler, it works (both on normal and elevated Powershell).</p>
  
  <pre><code>$currentDate = (Get-Date).AddDays(-1).ToString('yyyyMMdd');
  
  gci "C:\some_directory" | where-object { ($_.Name -match $currentDate) -and (! $_.PSIsContainer) } | Copy-Item -Destination "Y:\" -force;
  </code></pre>
  
  <p>and on task scheduler: Powershell -Command "c:\scripts\my_script.ps1"</p>