Skip to main content

Back-End Development

Setting Workflow on All Templates Using Sitecore PowerShell Extensions

Work In Nature@1x.jpg

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 🙂


Thoughts on “Setting Workflow on All Templates Using Sitecore PowerShell Extensions”

  1. Dylan McCurry

    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.

Leave a Reply

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

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

Diego Moretto

Diego is a software developer with over 13 years of experience. He enjoy building new things, solving problems, learning new technologies and becoming a better developer every day. Ten years ago he started working with .Net and became impassioned with the platform. Since early 2011 Diego's work has been fully dedicated to Sitecore and anything related to its ecosystem. He is a Sitecore certified developer and most recently was awarded the Sitecore Technology 2017, 2018 and 2019 MVP. In his personal time Diego likes playing video games and tennis, and spending quality time with family.

More from this Author

Follow Us