Setting Workflow on All Templates Using Sitecore PowerShell Extensions

The other day I had a requirement where I had to implement a new workflow on a Sitecore implementation. All of the existing templates needed to begin using this new workflow. As I’m a developer, every time I need to perform an action that is repetitive, I think about ways to automate it. In this case, since there were a few templates that needed to be updated, I thought about creating a simple Sitecore PowerShell script to update all of them.


Update All the Templates


Sitecore PowerShell Extensions is a great module to automate things that would otherwise require repetitive, time consuming, manual steps. Also, if you are a Sitecore developer and you are not using it yet, I would highly recommend you give it a try. It comes with a lot of nice features like reporting, integrations with Content Editor and Control Panel, as well as a ton of commands you can use to build your scripts and manipulate Sitecore data easily.


The Script

Ok, so back to my requirement. I came up with the following script (slightly adapted for this post):

$templates = Get-ChildItem -Path "/sitecore/templates/My Project Templates" -Recurse | Where-Object { $_.Name -match "__Standard Values" } | ForEach-Object{
$_.__Workflow = "{A5BC37E7-ED96-4C1E-8590-A26E64DB55EA}"



What this script is doing is getting all the standard values from the templates that are descendants from the path “/sitecore/templates/My Project Templates”, which is where the templates for my project were created. Then it is looping all the results and setting on the workflow field the GUID of the workflow I created which in this case was “{A5BC37E7-ED96-4C1E-8590-A26E64DB55EA}”.


Getting Started with PowerShell

Simple, right? Well that’s why I personally like to use the Sitecore PowerShell Extensions module as much as it makes sense, because it can make life easier. If you want, you can download it directly from here. Other resources to help you get going include this online book and community support on the #module-spe Slack channel.

Happy Sitecoring 🙂


Diego Moretto

I am a software developer with over 13 years of experience. I enjoy building new things, solving problems, learning new technologies and becoming a better developer every day. Ten years ago I started working with .Net and became impassioned with the platform. Since early 2011 my work has been fully dedicated to Sitecore and anything related to its ecosystem. I am a Sitecore certified developer and most recently I was awarded the Sitecore Technology 2017 MVP. In my personal time I like playing video games and tennis, and spending quality time with my family. Learn more about Diego Moretto.

1 comment on Setting Workflow on All Templates Using Sitecore PowerShell Extensions

Dylan McCurryJune 19, 2017 - Reply

Very nice! I recently had to implement something very similar. Here’s what I came up with (assuming $workflow and $finalState are guids, while $contentItems is a collection of pages which should have workflow):


# apply workflow to standard values
Get-ChildItem -Recurse “master:/path/to/page/templates” | Where-Object { $_.Name -match “__Standard Values” } | ForEach-Object {
$_.”__Default workflow” = $workflow

# apply workflow to content items
$contentItems | ForEach-Object {
$_.__Workflow = $workflow
$_.”__Workflow state” = $finalState


Always love seeing people use this module.

Add a Comment

Your email address will not be published. Required fields are marked *

Or request call back