Skip to content

Instantly share code, notes, and snippets.

@vtml
Created October 25, 2023 04:28
Show Gist options
  • Save vtml/54dd9d112e90bcaaa9698844e810a79e to your computer and use it in GitHub Desktop.
Save vtml/54dd9d112e90bcaaa9698844e810a79e to your computer and use it in GitHub Desktop.
Subject Matter Experts Content Approvers Restrictions
# Create a list of field names on the Standard Template. This will help us filter out extraneous fields.
$standardTemplate = Get-Item -Path "master:" -ID "{1930BBEB-7805-471A-A3BE-4858AC7CF696}"
$standardTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$standardTemplate
$standardFields = $standardTemplateTemplateItem.OwnFields + $standardTemplateTemplateItem.Fields | Select-Object -ExpandProperty ID -Unique
$itemTemplate = Get-Item -Path "."
$itemTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$itemTemplate
$itemTemplateFields = $itemTemplateTemplateItem.OwnFields + $itemTemplateTemplateItem.Fields | Select-Object -ExpandProperty ID -Unique
$filterFields = $itemTemplateFields | Where-Object { $standardFields -notcontains $_ } | Get-Item | Sort-Object
$role = "sitecore\Subject Matter Experts Content Approver"
$acl = New-ItemAcl -AccessRight field:write -PropagationType Any -SecurityPermission DenyAccess -Identity $role
$filterFields | Add-ItemAcl -AccessRules $acl
Show-Alert "Updated $($filterFields.Count) fields to be read-only for Subject Matter Experts Content Approvers."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment