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.
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
- Start the “Basic Task” wizard.
- “Create a Basic Task” – Give your task a friendly name (“PowerShell – Daily Running Service Report”) and description.
- “Trigger” – Set to Daily and set the time to “7:30 AM”.
- “Action” – Set to Start a Program. Program/Script is “PowerShell”. Add argument for your script (“C:\scripts\dailyjob.ps1”)
- 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.