Skip to main content
2 of 4
added 57 characters in body
Michael West
  • 18.6k
  • 2
  • 42
  • 105

Delegated Administration with SPE

Let's say for example that you wanted to provide a Context Menu option for users to unlock items based on the following criteria.

  • Show when User is in the sitecore\Delegated Admin role
  • Enable when the item is locked

In between cooking eggs at home I was able to whip this up.

Unlock Elevated

So here is how I built it.

  1. Create a new SPE Module with a Context Menu library.
  2. Create a new script for unlocking the selected item.
  3. Configure a rule for Show and Enable when certain conditions are met.

Script with Rules

Now the user is able to Lock and Edit.

Lock and Edit

Sample script for Unlock Elevated:

$item = Get-Item -Path .
# The user should be one granted the appropriate access.
$user = Get-User -Id "superuser"
New-UsingBlock (New-Object Sitecore.Security.Accounts.UserSwitcher $user) {
    $item | Unlock-Item
}

Note: This solution may be better suited as a Ribbon command. You can read more about how to do that here.

Michael West
  • 18.6k
  • 2
  • 42
  • 105