Running Script from Task Scheduler

I have a script that works fine as long as it can run in the foreground, or active session. However, if I don’t have it set to “Run only when user is logged on” it fails. I would like to get this moved over to unattended on a server. Is there a way to force Scheduler to run the script in the primary session?

You have to have it set to “Run whether user is logged on or not” and check the “Do not store password.” option. Then enter your password (or the password of the service account).

You can also use PowerShell to register the scheduled tasks. Check out this article: