Add Run PowerShell Script Step to SCCM Task Sequence

Let’s check how to add Run PowerShell Script Step to SCCM Task Sequence. The PowerShell script added to SCCM task sequence must be installed silently when you decide to add during the OS deployment.

This option helps SCCM Admin to perform various operations easily during the operating system deployment with Task sequence. The details to post will provide you insights about the available option with this step. As per Microsoft, The PowerShell Script must meet the following criteria –

  • PowerShell Script shouldn’t interact with the desktop, must run silently or in an unattended mode.
  • It must not initiate a restart on its own. The script must request a restart using the standard restart code, 3010. This behavior makes sure that the task sequence properly handles the restart. If the script does return a 3010 exit code, the task sequence engine restarts the computer. After the restart, the task sequence automatically continues.
  • Use signed PowerShell scripts in Unicode format. ANSI format, which is the default, doesn’t work with this step.

How to Add Run PowerShell Script Step to SCCM Task Sequence

Let’s follow the below steps to add Run PowerShell Script in the Task sequence and learn about the available options –

Create or Edit an Existing Task Sequence

Patch My PC

This Guide will help you to create a Configuration Manager task sequence from scratch. Use the following steps to modify an existing task sequence. 

  • In the Configuration Manager console, go to the Software Library workspace, expand Operating Systems, and then select the Task Sequences node.
  • In the Task Sequence list, select the task sequence that you want to edit. Select Edit to modify.
Add Apply Driver Package Step to SCCM Task Sequence

To add this step in the task sequence editor, select Add, select General and select Run PowerShell Script.

This step can be run in the full OS or Windows PE. To run PowerShell Script step in Windows PE, enable PowerShell in the boot image. Enable the WinPE-PowerShell component from the Optional Components tab in the properties for the boot image. More you can check

Add > General > Run PowerShell Script

Properties for Run PowerShell Script

  • On the Properties tab for Run PowerShell Script step, You can configure the following settings –
    • Package
    • Script name
    • Enter a PowerShell Script
    • Parameters
    • PowerShell execution policy
    • Start in
    • Time-out (minutes)
    • Run this step as the following account (Account)
Add Run PowerShell Script Step to SCCM Task Sequence 1
Add Run PowerShell Script Step to SCCM Task Sequence 8


Select this option to specify the Configuration Manager package that contains the necessary files for execution. It can contain multiple PowerShell scripts.


Script name

Specifies the name of the PowerShell script to run. For Example – FileName.ps1

Add Run PowerShell Script Step to SCCM Task Sequence 2
Add Run PowerShell Script Step to SCCM Task Sequence 9

Enter a PowerShell script

In this step, you can enter the PowerShell code directly. This feature lets you run PowerShell commands during a task sequence without distributing a package. If needed, you can directly do the changes and perform testing without looking into the package creation process and distribution.

When you add or edit a script, the PowerShell script window provides the following actions –

  • Edit the script directly.
  • Click Open an existing script from file
  • Browse to an existing approved script in Configuration Manager
Add Run PowerShell Script Step to SCCM Task Sequence 3
Add Run PowerShell Script Step to SCCM Task Sequence 10


If you use a script in a package, you can specify the parameters passed to the PowerShell script. These parameters are the same as the PowerShell script parameters on the command line.

PowerShell execution policy

Determine which PowerShell scripts you allow running on the computer. You can choose one of the following execution policies –

  • AllSigned: Only run scripts signed by a trusted publisher.
  • Undefined: Don’t define any execution policy.
  • Bypass: Load all configuration files and run all scripts. If you download an unsigned script from the internet, Windows PowerShell doesn’t prompt for permission before running the script.
Add Run PowerShell Script Step to SCCM Task Sequence 4

Start in

This field is optional. You can specify the executable folder for the program, up to 127 characters. This folder can be an absolute path on the destination computer or a path relative to the distribution point folder that contains the package.

Time-out (minutes)

This option is disabled by default. Specifies a value that represents how long Configuration Manager allows the command line to run. This value can be from one minute to 999 minutesThe default value is 15 minutes.

Run this step as the following account (Account)

Here you can specify the local user or domain account to run the command line. The command line runs with the permissions of the specified account. Select Set to specify the account.

Options for Run PowerShell Script

On the Run PowerShell Script step, Options tab. Here you can configure the additional settings of this task sequence step –

Continue on error – When you select Continue on error on the Options tab of this step, the task sequence continues when a PowerShell Script fails to execute. When you don’t enable this option, the task sequence fails and will not execute the remaining steps.

Success codes – Include other exit codes from the script that the step should evaluate as success.

Add Run PowerShell Script Step to SCCM Task Sequence 5
Add Run PowerShell Script Step to SCCM Task Sequence 11

Once you are done, click Apply and OK to save the changes. Close the task sequence editor, and the task sequence is ready for deployment.

About Author -> Jitesh has over 5 years of working experience in the IT Industry. He writes and shares his experiences related to Microsoft device management technologies and IT Infrastructure management. His primary focus area is Windows 10 Deployment solution with Configuration Manager, Microsoft Deployment Toolkit (MDT), and Microsoft Intune.


2 thoughts on “Add Run PowerShell Script Step to SCCM Task Sequence”

  1. how do you run a powershell script within a task sequence with administrator elevation ? I am trying to run a script to create registry entries to allow auto logon for a domain username, but the script fails with permission errors.
    I can run the same script manually by right clicking on powershell ISE and running as administrator. It creates the registry entries successfully if done this way by elevating the powershell window.
    Cant I run this as a step in a task sequence with elevation?

  2. Ensure your A/V or Malware program excludes C:\Windows\Temp\SMSTSPowerShellScripts folder and/or C:\Windows\CCM\OSDRunPowerShellScript.exe for embedded Task Sequence PS scripts. If your protection relies on File Hash properties, make sure all versions of OSDRunPowerShellScript.exe (different hashes for different versions of the CCM client) are excluded.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.