My powershell script wont save a file when run using Task Scheduler, do I need to specify a specific argument?

Posted by EGr on Server Fault See other posts from Server Fault or by EGr
Published on 2012-09-27T20:27:18Z Indexed on 2012/09/27 21:39 UTC
Read the original article Hit count: 235

I have a script that downloads a temporary Excel file, copies parts of it to a new file, and saves it to a specific location on the network. The problem I'm having is that the new file is never created/saved. If I run the script locally (through cmd.exe, powershell, or powershell ise), it WILL save the file locally, or to the network. If I try running the script via a schedule or on-demand via Task Scheduler, the temporary file is created, but the final document is never created or saved. Is there a specific argument I need to pass, or anything I could be doing wrong? This is the command I'm currently using:

    powershell.exe -file C:\path\to\my\powershell\script\thescript.ps1

Since it calls environment variables, and other variables relative to the scripts positon, I also set "Start in" to

    C:\path\to\my\powershell\script\

© Server Fault or respective owner

Related posts about Windows

Related posts about windows-7