How to Setup a PowerShell Script to Run as a Scheduled Task

Using PowerShell 9 Replies

Alright, so you’ve built up your skills, developed your script, got all the kinks worked out and now it’s time to set the sucker up to do your work for you.  I know, I’ve been there myself.
How to Start a PowerShell Script as a Scheduled Task

This tutorial shows you how to setup a scheduled task to run your PowerShell scripts’

So now that you’ve gotten yourself ready to automate you’ll need to configure your scheduled task correctly.

For this example I’ll use the script I made for outputting the running services by creating a daily html file with PowerShell.

I’ve saved my dailyjob.ps1 file to my scripts directory, and my desired outcome is that is runs automatically every morning at 7:30 AM.

In Windows 7, press the “Win” key, and search the start menu for “Task”.  You may need to turn on administrative tools if it isn’t already on.

Follow these easy steps to add your dailyjob.ps1 as a scheduled task

  1. Start the “Basic Task” wizard.
  2. “Create a Basic Task” – Give your task a friendly name (“PowerShell – Daily Running Service Report”) and description.
  3. “Trigger” – Set to Daily and set the time to “7:30 AM”.
  4. “Action” – Set to Start a Program.  Program/Script is “PowerShell”.  Add argument for your script (“C:\scripts\dailyjob.ps1”)
  5. Finish

Great!  super easy, right?

An extra note – if you’re redirected your profile to a network share, and now PowerShell asks you to confirm you’re ok with running your profile across the network, this can gum up your automated tasks.  If that is your situation, add a “/noprofile” switch to the arguments on your “Action” settings.

9 thoughts on “How to Setup a PowerShell Script to Run as a Scheduled Task

  1. Pingback: Tweets that mention How to Setup a PowerShell Script to Run as a Scheduled Task | I Love Powershell -- Topsy.com

  2. Daryl

    hello

    thanks for the post, this may be a silly question but can i set this up to run as a scheduled task on windows XP? i have powershell installed but the task option is different

    Reply
  3. Pingback: Downloading the Results of a Twitter Search using PowerShell and SQL (part 3) | SELECT STUFF FROM SQL

  4. Paige

    Thanks, this was helpful.

    Just FYI:

    When you set up a scheduled task to run a PowerShell script in Windows 7 (or Server 2008) make sure you check the “Run with highest privileges” box.

    Reply
  5. Pingback: How to alter powershell command line for mongodb export into a Powershell script (for scheduled task purposes) | BlogoSfera

  6. John Porter

    For reasons I won’t go into, task scheduler is unavailable. Can a PS script be created that can be used as the task scheduler?

    Reply

Whats Your Take?