title: win 7 scheduler does not start a powershell script - what to do?
body: <p>I want the scheduler to start my powershell script. This script (re-)writes at first the time-stamp of its start:</p>
  
  <pre><code>   $StatusFile = $Env:USERPROFILE+"\Desktop\Status.log"
     set-content $StatusFile "Start $($((get-date).ToString('ddd. yyyy.MM.dd HH:mm:ss')))"
  </code></pre>
  
  <p>If this was written I can be sure the script (and not only powershell) has been started.</p>
  
  <p>I defined in the scheduler for this task<br>
  - user: SYSTEM and<br>
  - the highest privileges and all the other stuff of the other tabs.<br></p>
  
  <p>In the Actions-Tab I define:<br>
  1) Action = "Program start"<br>
  2) Programm/Skript = powershell.exe (or C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe)<br>
  3) Arguments (optional):</p>
  
  <pre><code>a)  C:\Users\calli\Desktop\TimeSync_v2.ps1
  b) -file "C:\Users\calli\Desktop\TimeSync_v2.ps1"
  c) -command "C:\Users\calli\Desktop\TimeSync_v2.ps1"
  d) -file C:\Users\calli\Desktop\TimeSync_v2.ps1
     ....
  </code></pre>
  
  <p>No matter what I enter in the Arg.-Line I can always start the task and the task keeps running<br>
  but the file Status.log was never re-written. So the scheduler starts only powershell but not my script??</p>
  
  <p>If I try (got that from google) to enter all in the Programm/Skript-line (leaving Args. empty) like:</p>
  
  <pre><code> powershell.exe -file "C:\Users\calli\Desktop\TimeSync_v2.ps1"
  </code></pre>
  
  <p>(even here various versions) I immediately get a launch error and nothing was running.</p>
  
  <p>I even tried to set: s.th. like kill a running instance if a new one is started (if I remember correctly).</p>
  
  <p>What do I have to do? Where is my fault?</p>
  
  <p>Thanks in advance,<br>
  Gooly</p>
  
  <p>I added the result of my tries to run the script. I either get the launch error (2nd try) the other two are running but none of them writes the time-stamp in the log-File
  The initial script-lines:</p>
  
  <pre><code>  $StatusFile = $Env:USERPROFILE+"\Desktop\TimeSyncStatus.log"
    set-content $StatusFile "Starte TimeSync $($( (get-date).ToString('ddd. yyyy.MM.dd HH:mm:ss') ))"
    do { chkSync } while ( $true )
  </code></pre>
  
  <p>1st Try (briantist)</p>
  
  <pre><code>  Action: powershell -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File 'C:\Users\calli\Desktop\TimeSync_v2.ps1'"
    Add Args: -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File C:\Users\calli\Desktop\TimeSync_v2.ps1"
    Start in: (empty)
    Task Scheduler started "{fad9623d-7527-48c7-a95c-4adac7e0dba2}" instance of the "\start TimSync" task for user "WORKGROUP\MYMSI$".
    Task Scheduler launched action "powershell" in instance "{fad9623d-7527-48c7-a95c-4adac7e0dba2}" of task "\start TimSync".
    Task Scheduler launch task "\start TimSync" , instance "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.EXE"  with process ID 5824.
  </code></pre>
  
  <p>2nd Try (launch error)</p>
  
  <pre><code>  Action: powershell "-NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File 'C:\Users\calli\Desktop\TimeSync_v2.ps1'"
    Add Args:
    Start in:
    Task Scheduler launched action "powershell "-NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File 'C:\Users\calli\Desktop\TimeSync_v2.ps1'"" in instance "{653f5e6a-e992-44d0-8189-fda1d44a114f}" of task "\start TimSync".
    Task Scheduler failed to launch action "powershell -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File 'C:\Users\calli\Desktop\TimeSync_v2.ps1'" in instance "{653f5e6a-e992-44d0-8189-fda1d44a114f}" of task "\start       TimSync". Additional Data: Error Value: 2147942523.
    Task Scheduler failed to start instance "{653f5e6a-e992-44d0-8189-fda1d44a114f}" of "\start TimSync"  task for user "WORKGROUP\MYMSI$" . Additional Data: Error Value: 2147942523.
  </code></pre>
  
  <p>3rd Try (Matt)<br></p>
  
  <pre><code>  Action: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
    Add arguments: -ExecutionPolicy Unrestricted -NoProfile -File C:\Users\calli\Desktop\TimeSync_v2.ps1
    Start in: Start in (optional): %SystemRoot%\system32\WindowsPowerShell\v1.0
    Task Scheduler started "{3c00ad49-e8a0-48a2-9578-90b512db0932}" instance of the "\start TimSync" task for user "WORKGROUP\MYMSI$".
    Task Scheduler launched action "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" in instance "{3c00ad49-e8a0-48a2-9578-90b512db0932}" of task "\start TimSync".
    Task Scheduler launch task "\start TimSync" , instance "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe"  with process ID 8980.
  </code></pre>