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):
- Selected the option to run whether user is logged on or not.
- Set to run with the highest privleges
- Have checked and rechecked that my
ExecutionPolicy
isUnrestricted
.
Edit: Since that picture is so small here is a direct link: http://imgur.com/EX7Vxj7
-noexit
flag in the arguments for powershell.exe? - Mathias R. Jessenpowershell.exe script.ps1
, it runs the script. When you executepowershell -noexit script.ps1
, it runs the script but doesn't exit the process afterwards. That doesn't seem to be the case though - Mathias R. Jessen