How to Schedule a PowerShell Script to Auto Run On a Windows Server




If you want your PowerShell script to auto run at specific intervals you need to schedule the PowerShell script with Windows task scheduler.

There are other tools you can use to schedule a PowerShell script to run at specified times but this guide demonstrates how to do this with the Windows task scheduler

I will use the PowerShell script shown below for demo on this guide. The script creates folders if the folder does not exist in the directory.


Time needed: 5 minutes.

To Schedule a PowerShell Script to auto on a Windows Server, follow the steps below:

  1. Open Windows Task Scheduler

    Type task scheduler into the search box. Then click Task Scheduler.

  2. Create a New Task

    Right-click Task Scheduler Library. Then select Create Task.

    Schedule a PowerShell Script

  3. Name the task and Enter an optional description

    On the general tab of the new task give the task a name using the name field. You may also describe the task using the description box.

    On the box labelled 3, be sure to select Run whether user is logged on or not. If you select the first option the scheduled PowerShell script will not run unless the user is logged on.

  4. Create a Trigger to Auto run the Scheduled PowerShell Script

    To do this, click the triggers tab. Then click New. The New Trigger window will open.

    On the Begin the task drop-down, ensure that On a schedule is selected. Then select whether you want to Schedule the PowerShell Script to run Daily, Weekly or Monthly.

    You may also wish to schedule the PowerShell script to repeat at specific interval. To do this, check the Repeat task every box. Then click the drop-down to select a period.

    Another very important configuration is the Stop task if it runs longer than setting. Check this box to automatically stop the scheduled task. You may also set an expiry date for the task. The task will stop running after the set date.

    When you finish configuring the trigger, click Ok.

    Schedule a PowerShell Script

  5. Schedule the PowerShell script using the Actions tab

    Click the Actions tab. Then click New. On the Action drop-down, ensure that Start a program is selected. Then type PowerShell.exe on the program/script field.

    Next, enter the -File followed by the full path to the script on the Add arguments (optional) field. Here is the command I typed in the Add arguments (optional) field:

    -File “C:\PS\schedule powershell example\Create-folders-from-text-file.ps1”

    When you finish click Ok. Then click Ok again. When you click Ok, the second time, you will be required to confirm your password.

    Schedule a PowerShell Script

  • On the Username field, use the format ComputerName\username or Domainname\Username.

When you finish, here is what the Actions tab will look like. Effectively, you are asking task scheduler to run this command –

PowerShell.exe -File "C:\PS\schedule powershell example\Create-folders-from-text-file.ps1"
To confirm that the powershell script will run as scheduled, right-click the task and select Run.


For your script to run you need to use the -File parameter of the PowerShell.exe command in the actions tab. This is the trick. Otherwise your script may not run.

I hope you found this guide helpful. To leave a comment, suggestion or ask a question use the “Leave a Reply” form at the end of this page.

Other Helpful Guides

Additional Resources and References


Please enter your comment!
Please enter your name here


network discovery keeps turning off server 2016

How to Fix Network Discovery If it Keeps Turning Off in Server 2016

Does network discovery keep turning off in your Windows server 2016? It is likely that one of its dependent services is not...
how to install windows 10 1903 update manually

How to Install Windows 10 1903 Update Manually

Windows 10 1903 Update was released in May, 2019. But some users are not yet offered the update via automatic update. The...
spotify web player not working

Spotify Web Player Not Working [Fixed]

Introduction Spotify Web Player may stop working for you with the following error messages: "Spotify Web Player an Error...
DISM.exe /Online /Cleanup-Image /Restorehealth

DISM.exe /Online /Cleanup-Image /Restorehealth Explained

What is DISM.EXE /Online /Cleanup-image /RestoreHealth? "DISM.exe /Online /Cleanup-Image /Restorehealth" is a DISM command that repairs issue with the...
DHCP Relay agent

DHCP Relay Agent: Configuration in Windows Server 2016

What is a DHCP Relay Agent? A DHCP Relay Agent allows DHCP clients in a different network subnet to...


Remote Desktop Connection

Remote Desktop Connection an Internal Error Has Occurred [Fixed]

Introduction I recently received the error message "Remote Desktop Connection an Internal Error Has Occurred". It was strange because...

Find My Samsung: Register and Use Samsung Find my Mobile

Introduction Ever wondered how you could find your Samsung phone if you lost it? Find my Samsung or Samsung...
What is the Difference Between PowerShell and CMD?

Windows Powershell vs CMD: Differences and Similarities

Introduction This short guide compares Windows PowerShell vs CMD (Windows command prompt). I will cover the history and nature...
Spotify No Longer Supports this Version of Microsoft Edge

Spotify No Longer Supports this Version of Microsoft Edge [Fixed]

Introduction When you open Spotify web player on Microsoft Edge, you may receive the error message "Spotify No Longer...
Windows 10 Won't Boot

Windows 10 Won’t Boot With Black Screen? 3 Ways to Fix It

Why Won't Windows 10 Boot Up? If your Windows 10 stops with a black screen, the first question in...


powershell executionpolicy

PowerShell ExecutionPolicy Explained

What is PowerShell ExecutionPolicy? ExecutionPolicy in PowerShell is a security feature that controls how PowerShell loads configuration files and...
how to share screen on skype

How to Share Screen on Skype on Desktop and Mobile Apps

Introduction What determines how you share screen on Skype depends on a number of factors: Where...

How to Fix “BootMgr is Missing” Error in Windows 10

Introduction If you receive Fix "BootMgr is missing" Error in Windows 10, the default response is panic! But you...
Dual Boot Windows 7 and 10

Dual Boot Windows 7 and 10: Step by Step Guide

Introduction Want to try Windows 10 without upgrading? One option is to dual boot windows 7 and 10. ...
Amazon Baby Registry

Amazon Baby Registry: Your Definitive Guide

Introduction Amazon Baby Registry allows expectant mothers to create a list of items they need for their baby. Friends...


disable cortana windows 10 featured

How to Disable Cortana in Windows 10 (2 Methods)

Introduction Some Windows 10 users may not like Cortana. Solution? Disable Cortana. You are probably reading this because you...
bootrec /fixboot access is denied

How to Fix BootRec /FixBoot Access is Denied Error in Windows 10

Introduction BootRec /FixBoot Access is Denied Error in Windows 10? This error is likely caused by corrupt EFI directory.
Reset Windows 10

How to Reset Windows 10 (2 Methods)

Introduction If your Windows 10 is broken, one available way to fix it is to use Windows 10 reset....
system restore windows 10

How to Enable and Use System Restore in Windows 10

Introduction System restore in windows 10 is a very important tool that is probably ignored by most users. But...
windows has stopped this device code 43

How to Fix Windows Has Stopped this Device Code 43 Error

Introduction Sometimes you may receive "Windows has stopped this device code 43" error. This error is likely to come...
Windows could not automatically detect this network's proxy settings

How to Fix “Windows Could not Automatically Detect this Network’s Proxy Settings”

Introduction You suddenly lose the ability to connect to the internet. Then you run network troubleshooter and it returns...
printer offline

5 Ways to Restore Your Printer Online If Status is Offline

Introduction Is your printer offline? Setting it online is very simple but sometimes it is more than just setting...

How to Fix “BootMgr is Missing” Error in Windows 10

Introduction If you receive Fix "BootMgr is missing" Error in Windows 10, the default response is panic! But you...
windows 10 search featured

How to Fix Windows 10 Search If it Stops Working

Introduction Are you having troubles with Windows 10 search? Apparently, it is a fairly common problem with a number...
oooops, something went wrong. reload

How to Fix “Oooops something went wrong. reload” Spotify Error

Introduction If you receive "Oooops something went wrong. reload" Spotify error, do not panic. The fix is simpler than...


How to Dual Boot Ubuntu and Windows 10

How to Dual Boot Ubuntu and Windows 10

Introduction This is a step by step guide to dual boot Ubuntu and Windows 10 on the same computer....

Excel Substring: How to Get (Extract) Substring in Excel

Introduction An Excel substring is a portion of a text in a cell. For instance, if a cell contains...
Dual WhatsApp account in one phone

How to Use Dual WhatsApp Accounts in One Android Phone

Introduction Most Android phones now support dual SIM. If your Android phone has 2 SIM cards you can configure...
Transfer Schema Master Role

Transfer Schema Master Role With MMC or NTDSUTIL Command Tool

Introduction There are situations when an administrator may need to transfer the schema master role from one Domain Controller...
Wifi doesn't have a valid IP configuration

How to Fix “Wifi Doesn’t Have a Valid IP Configuration” Error

Introduction "Wifi doesn't have a valid IP configuration" error is common among Windows users. When you receive this error...

By using this website you agree to accept our Privacy Policy and Terms & Conditions