A Week of Task Sequence Tips - Day 07 - Run PowerShell Step

It's Day 7 in this non-consecutive 7 days of tips, and it's the last Task Sequence Tip of the mini series... volume 1. As much as the ConfigMgr team has built into the product, they can't do it all. We can write a million uservoice requests, but at the end of the day, a good ConfigMgr admin needs PowerShell to go beyond the basics and really be creative. The ConfigMgr team knows this, and they've empowered us to make the most out of powershell with the Run PowerShell Step.

For awhile, we used to have to use the Run Command Line Step, call the powershell.exe and either get creative with a powershell command or call a script in a package. Then they gave us the Run PowerShell Script Step, which made it easier, we could put in a script name, associate a package and it would just run. Then in 1902, they gave us the magic sauce that made the step super special. We can now embed a full powershell script right into the step, or easily create a TS Variable by piping the output of the script into a variable.

The "old days" of using PowerShell in the Task Sequence
The "old days" of using PowerShell in the Task Sequence
Using the 1902+ Step to create a variable from the powershell output
Using the 1902+ Step to create a variable from the powershell output
Calling a PowerShell Script File with a Reference Package
Calling a PowerShell Script File with a Reference Package
Embedding a Script right into the Task Sequence, no need for a Reference Package
Embedding a Script right into the Task Sequence, no need for a Reference Package!!!

This step is great, it is so flexible and allows you to do anything in a Task Sequence that you can imagine. Something I've done with PowerShell in that Task Sequence include:

  • Create Variables
  • Read & Trigger a Baseline
  • Setting Registry Keys
  • Trigger Client Actions (HWInv)
  • Launch XAML Forms or PowerShell driven Frontends
  • PreFlight Checks
  • Splash Screen

So until all of those things are native CM Task Sequence Steps, we have powershell, and with the updated PoweShell Step, it makes things SO MUCH Easier.

The BEST part of the updated step is embedding scripts, removing the requirement for a reference package. This ability has allowed me to be much more agile in fixing bugs in scripts than it would have been in a package. Changing a package in Production.. HUGE DEAL... making a minor step change in the TS... NO DEAL.

So my tip.. start converting batch files, powershell scripts into embedded powershell scripts with no required content.

I hope you enjoyed the 7 days of Task Sequence Tips.  If you have any questions or comments on any of them, hit me up on twitter @RecastSoftware

If you found this mini series useful, let us know and we'll come up with some more, and feel free to suggest topics. Thanks for tuning in!

See more tips:

Day 01 - Tag Version in Description

Day 02 - Task Sequence Pause

Day 03 - Variables Gather and Capture

Day 04 - SMSTS Log Stamping

Day 05 - Run Task Sequence Step

Day 06 - Static IP Addresses and OSD