# Running Script from Task Scheduler

**URL:** <https://forums.powershell.org/t/running-script-from-task-scheduler/9939>\
**Category:** PowerShell Help\
**Created:** [January 5, 2018, 9:21am UTC](https://forums.powershell.org/t/running-script-from-task-scheduler/9939 "2018-01-05T09:21:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mobob65746](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mobob65746](https://forums.powershell.org/u/mobob65746)\
**Post date:** [January 5, 2018, 9:21am UTC](https://forums.powershell.org/t/running-script-from-task-scheduler/9939/1 "2018-01-05T09:21:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jacorbello](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@jacorbello](https://forums.powershell.org/u/jacorbello)\
**Post date:** [January 5, 2018, 9:29am UTC](https://forums.powershell.org/t/running-script-from-task-scheduler/9939/2 "2018-01-05T09:29:41Z")

</div>

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:  
[https://blogs.technet.microsoft.com/heyscriptingguy/2015/01/13/use-powershell-to-create-scheduled-tasks/](https://blogs.technet.microsoft.com/heyscriptingguy/2015/01/13/use-powershell-to-create-scheduled-tasks/)

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:36pm UTC](https://forums.powershell.org/t/running-script-from-task-scheduler/9939/3 "2024-05-16T20:36:56Z")

</div>

Closed on May 16, 2024, 8:36pm UTC


