The Blog

Scheduling PowerShell Tasks: Quick Overview

This post is a quick summary demonstrating how to run a PowerShell script from the Task Scheduler without and with passing parameters.

Run PowerShell Scripts from Windows Task Scheduler

Task-Schedulder-Action

Scheduling a PowerShell Script without Script Parameters

Program/script:

The Program to run is PowerShell.exe. This will run the PowerShell process and the next step (arguments) will run the script.

 PowerShell.exe

Add arguments (optional):

The argument should contain the path to the PowerShell script to be run. This works because the command argument "-File"

<em>C:\Script1.ps1</em>

Running a PowerShell Script from Task Scheduler with Parameters

Task-Schedulder-Action with Parameters

Scheduling a PowerShell Script with Script Parameters

Program/script:

PowerShell.exe

Add arguments (optional):

We use "-Command" argument to identify that we want to run the script file and pass through parameters. Executes the specified commands (and any parameters) as though they were typed at the Windows PowerShell command prompt, and then exits, unless the NoExit parameter is specified.

-Command "&amp; <em>'C:\ScriptFile.ps1</em>' <em>-Param1 'Value1' -Param2 'Value2</em>'"

Everything after "-Command" must be enclosed in double quotes and where you would normally use double quotes without the command replace them with single quotes.

Neil Bryan
IT Consultant & Technical Trainer
Neil Bryan is an IT consultant and technical trainer specializing in VMware, Citrix and Microsoft virtualization and infrastructure.

Leave a Reply

Skip to toolbar