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.
Start typing to search...
A PowerShell script for a head start on setting up content security and workflow in Sitecore.
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.
To simplify role management, we organize our roles into four distinct categories: Content, Language, Workflow, and Miscellaneous.
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”
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”
Roles to control the approval process of a page.
Eg. “sitecore\Workflow Approver”, “sitecore\Workflow Editor”
Any other role that doesn’t fall in any of the three previous categories.
Eg. “sitecore\Basic Access”, “sitecore\Can Unlock Others Items”
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\Ana
“sitecore\Basic Access” is set into the “sitecore\Workflow” roles for convenience.

Creating a user based on all the three roles type
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.

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.

The script will not perform this action. You can create a script on your own targeting the correct items or assign manually.
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],