PowerShell Script For Creating Roles and Permission Part 1
Hello everyone, As we all know managing user roles and permissions effectively is crucial for maintaining security and ensuring appropriate access within any organization. In this blog post, we'll delve into the user roles and permissions hierarchy at ABC company. We'll explore the different roles, their specific permissions, and how these roles interrelate to form a cohesive and secure system especially when we have multiple website with multisite setup.
We will see, how we can implement this using PowerShell.
Lets consider, we have a company called ABC which is having corpate website followed by Country level site. The company have below roles. The hierarchy of the Site is ABC(Tenant) --> External(Site Collection) --> IN(Site)
- ABC Limiter
- ABC Author
- ABC External IN Access
- ABC External IN Content Previewer
- ABC External IN Content Contributor
- ABC External IN Content Publisher
- ABC External IN Content Admin
- ABC External IN Site Admin
Each role has specific permissions and, in many cases, inherits permissions from other roles. Let’s break down these roles and their permissions in detail
ABC Limiter
- Read Access to Site Collection and Parent level folder
ABC Author
- Read Access to everything
ABC External IN Access
- Inherits permissions from ABC Limiter
- Default Site Collection access (descendants: no).
- Access to Region Node (descendants: no).
- Access to Site (descendants: yes).
- Access to Media IN (descendants: yes).
- Access to System-->Settings-->Projects (descendants: yes).
ABC External IN Content Previewer
- Inherits read access from ABC External IN Access, with access to Site, Media, and System including all descendants.
ABC External IN Content Contributor
- Read Access: Inherits from ABC Author and ABC External Content Previewer.
- Write Access with descendants on Home, Media, and Data.
- Create on Home, Media with descendants, and descendants of Data Item.
ABC External IN Content Publisher
- Inherits from ABC External IN Content Contributor and includes the Sitecore Client Publishing Role.
ABC External IN Content Admin
- Inherits from ABC External IN Content Publisher.
- Additional permissions to rename and delete descendants of Home, Media, and Data folders.
ABC External IN Site Admin
- Inherits from ABC External Content Admin.
- Additional permissions to write, rename, create, and delete sites and all their descendant folders, media, and shared folders.
Now let's see how we can add the roles using powershell.
$siteLanguages = @("en-IN")
$siteName = "IN"
$siteType = "External"
$Organization = "ABC"
$rolePrefix = "$Organization $siteType $siteName"
$siteAccessRole = "$rolePrefix Access"
$siteAdminRole = "$rolePrefix Site Admin"
$contentAdminRole = "$rolePrefix Content Admin"
$contentContributorRole = "$rolePrefix Content Contributor"
$contentPublisherRole = "$rolePrefix Content Publisher"
$contentPreviwerRole = "$rolePrefix Content Previewer"
New-Role -Identity $siteAccessRole
Add-RoleMember -Identity "ABC Limiter" -Members $siteAccessRole
New-Role -Identity $contentPreviwerRole
Add-RoleMember -Identity $siteAccessRole -Members $contentPreviwerRole
Add-RoleMember -Identity "Designer" -Members $contentPreviwerRole
New-Role -Identity $contentContributorRole
Add-RoleMember -Identity $contentPreviwerRole -Members $contentContributorRole
Add-RoleMember -Identity "ABC Author" -Members $contentContributorRole
New-Role -Identity $contentPublisherRole
Add-RoleMember -Identity $contentContributorRole -Members $contentPublisherRole
Add-RoleMember -Identity "Sitecore Client Publishing" -Members $contentPublisherRole
New-Role -Identity $contentAdminRole
Add-RoleMember -Identity $contentContributorRole -Members $contentAdminRole
Add-RoleMember -Identity "ABC Approver" -Members $contentAdminRole
Add-RoleMember -Identity "Sitecore Client Publishing" -Members $contentAdminRole
New-Role -Identity $siteAdminRole
Add-RoleMember -Identity $contentAdminRole -Members $siteAdminRole
The above script is creating the required role and assigning exitsing role as member. To learn more about it you can follow the references section given below.
In the next part, we will see how we create new access rule for the specified roles. Stay tune!!
You can check my other blogs too if interested. Blog Website
References:
- https://doc.sitecorepowershell.com/appendix/security/new-role#syntax
- https://doc.sitecorepowershell.com/appendix/security/add-rolemember#syntax
Comments
Post a Comment