Search

Scheduled Task for Powershell does not observe the Tasks "start in" directory by Craig S Williams

Active

1
0
Sign in
to vote
Type: Bug
ID: 771860
Opened: 11/21/2012 9:25:18 AM
Access Restriction: Public
0
Workaround(s)
0
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
Details (expand)
How often does this happen?
Always Happens

Have you seen this problem before in this product?

I don't know if this issue existed previously
Reproduction Steps
Create a scheduled task for a powershell script that leverages $pwd and try to run it

arguments    -noninteractive -file .\test.ps1
or
arguments    -noninteractive -file c:\temp\test.ps1
start in    c:\temp
Expected Results
The $pwd should always be the same as the "start in" path specified for the task
File Attachments
0 attachments
Sign in to post a comment.
Sign in to post a workaround.