Reading time: 7 min read

Simplifying Content Security and Workflow Initial Setup in Sitecore

A PowerShell script for a head start on setting up content security and workflow in Sitecore.

Portrait photo of Roberto Barbedo, article author

Establishing a Basic Security and Workflow Configuration

Setting up content security and workflows in Sitecore can often feel daunting, especially when starting from scratch. While Sitecore offers granular control and flexibility, most websites only need a basic setup to get started. This post provides a PowerShell script that establishes a foundational configuration for security, workflows, and roles, covering the essentials for most scenarios.

In XM Cloud, configuring workflows is particularly crucial because publishing often includes additional items resolved through references. Without workflows, draft content may be unintentionally published, leading to incomplete or inaccurate updates. A workflow is the only reliable way to ensure that only approved content is published.

Roles: Organizing Roles for Effective Access Management

To simplify role management, we organize our roles into four distinct categories: Content, Language, Workflow, and Miscellaneous.

Content

Roles to control the access to parts in the content tree. It can be an entire site, or a section of a site.

Eg. “sitecore\Content SiteA”, “sitecore\Content News”

Language

On multi-language websites, you can define what language an author can edit. Normally, all authors edit all languages.

Eg. “sitecore\Language en_CA”, “sitecore\Language All”

Workflow

Roles to control the approval process of a page.

Eg. “sitecore\Workflow Approver”, “sitecore\Workflow Editor”

Miscellaneous

Any other role that doesn’t fall in any of the three previous categories.

Eg. “sitecore\Basic Access”, “sitecore\Can Unlock Others Items”

Users: Assigning Roles to Users by Type

Users will always be members of at least one Content, Workflow, and one Language role. This approach allows composition of roles to define what different authors can do.

Examples:

sitecore\Mario

  • sitecore\Content SiteA
  • sitecore\Language All
  • sitecore\Workflow Editor

sitecore\Ana

  • sitecore\Content SiteA
  • sitecore\Language All
  • sitecore\Workflow Approver

“sitecore\Basic Access” is set into the “sitecore\Workflow” roles for convenience.

Sitecore role assignment dialog showing selected roles

Creating a user based on all the three roles type

Workflow: Basic Three States Setup

The PowerShell script below creates a copy of the out of box “Sample Workflow”. The sample workflow offers a simple three step process that is applicable for most organizations.

The name of the copy can be configured in the script, review all variables on the top before running it.

Sitecore Workflows content tree showing a “Custom Workflow” with three states: Draft, Awaiting Approval, and Approved

Templates: Define Default Workflow in Standard Values

After executing the script, the last step is to add templates in workflow. The field “Default Workflow” needs to be set in the standard values of all pages and components.

Sitecore Content Editor showing the __Standard Values item selected, with the “Default workflow” field set to “Workflows/Custom Workflow

The script will not perform this action. You can create a script on your own targeting the correct items or assign manually.

Script: Setting Up All in a Single Run

Replace the variables and execute the script. This script can be executed multiple times safely.


,[object Object],
,[object Object],
,[object Object], = ,[object Object],  
,[object Object], = ,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],
,[object Object],

[object Object], ,[object Object], = ,[object Object], + ,[object Object], ,[object Object], = ,[object Object], -Path ,[object Object], ,[object Object], ,[object Object], ,[object Object], ,[object Object], -ForegroundColor Green ,[object Object], ,[object Object], ,[object Object],.ID -ForegroundColor Green ,[object Object], ,[object Object],