Windows PowerShell Home
Scheduled Task for Powershell does not observe the Tasks "start in" directory
Craig S Williams
11/21/2012 9:25:18 AM
User(s) can reproduce this bug
Not sure if this is defect of the Task Scheduler or Powershell.
Using psv2 on 2008R2.
When the task "program" is "powershell" the "Start in" path is observed and the $pwd of the script execution is the "start in" dir
However, when the task "program" is "powershell.exe" the "Start in" path is NOT observed and the $pwd of the script execution is C:\windows\system32
So when the script writes to a file, and you expect the current dir to be the "start in" dir, it is not unless you remember to make the tasks "program" = "powershell" without .exe
How often does this happen?
Have you seen this problem before in this product?
I don't know if this issue existed previously
Create a scheduled task for a powershell script that leverages $pwd and try to run it
arguments -noninteractive -file .\test.ps1
arguments -noninteractive -file c:\temp\test.ps1
start in c:\temp
The $pwd should always be the same as the "start in" path specified for the task
to post a comment.
Please enter a comment.
to post a workaround.
Please enter a workaround.
© 2013 Microsoft