Reputation: 65
I have written two powershell scripts that I need to run every morning. The first generates a text file of the names and location of all of the new files added to a directory within the last twenty-four hours. The second script that I wrote takes that .txt file and e-mails it to myself.
Both of these scripts run perfectly when executed manually. I added them both to the task scheduler but the scheduler does not properly execute the scripts. The text file does not get generated, and the e-mail does not get sent.
Things that I have done (for both scripts):
ExecutionPolicy
is Unrestricted
.Edit: Since that picture is so small here is a direct link: http://imgur.com/EX7Vxj7
Upvotes: 1
Views: 1773
Reputation: 947
If your script is located on a shared map you need to provide unc to the file like this:
\\servername\script.ps1
You can find more details in this post: https://dmitrysotnikov.wordpress.com/2011/02/03/how-to-schedule-a-powershell-script/
Upvotes: 0
Reputation: 1620
The Action needs to be set to "Start a program" and the program should be PowerShell.exe
Secondly in the Add Arguments box you need to enter -File '[script path]'
. You can add -NoExit
if you want to keep the window open afterwards but it will need to be running as your own user of course.
Upvotes: 1