So you’ve got a PowerShell script and now you need to run it at particular times, how exactly do you do that?

Enter Microsoft’s handy tool – Task Scheduler.

Note: You should always make sure that the script is 100% ready to go and has been tested in a test environment before you run it on a production server.

  1. First, I recommend placing the script in a folder somewhere on the local drive of the machine. For this example we’ll use C:\Scripts
  2. Open Microsoft Task Scheduler, select the ‘Task Scheduler Library’ from the left hand pane, then right click in an empty space and select ‘Create Basic Task’
  3. Give the task a name and enter a description
  4. Select how often you would like the task to run
  5. Then select the starting time and date for the task as well as when it should recur
  6. Select what you want the task to do, in this case we’ll select ‘Start a program’
  7. Enter ‘PowerShell.exe’ for the Program/Script. Under arguments enter this: -File “path to your script” so in this example: -File “C:\Scripts\MyPowerShellScript.ps1”
  8. On the final page you can review your task and then select ‘Finish’
  9. Now if you’d like to manually run your task to test it, you can right click and select ‘Run’

This process will work for scripts that don’t require authentication locally or to an external resource like Office 365. I will cover how to include authentication in a later post.

 

1 COMMENT

Comments are closed.