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.
So here is how I built it.
- Create a new SPE Module with a Context Menu library.
- Create a new script for unlocking the selected item.
- Configure a rule for Show and Enable when certain conditions are met.
Now the user is able to 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.
Turns out Richard Seal apparently had the same idea today and hosted this.