Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Transfer lock ownership from one user to another using Sitecore PowerShell Extensions.
Find all items locked by a specific user and transfer to another user.
This report helps identify all of the items locked by a user and transfers to another user.
Michael West
$scriptItem = Get-Item -Path $SitecoreCommandPath
$icon = $scriptItem.Appearance.Icon -replace "16x16","32x32"
$settings = @{
Title = "Report Filter"
Width = "450"
Height = "250"
OkButtonName = "Proceed"
CancelButtonName = "Abort"
Description = "Filter items locked by a specific user."
Parameters = @(
@{ Name = "userLockOwner"; Title="Current User"; Editor="user"; Domain="sitecore"; },
@{ Name = "userNewLockOwner"; Title="New User"; Editor="user"; Domain="sitecore"; }
Icon = $icon
$result = Read-Variable @settings
if($result -ne "ok") {
$reportProperties = @{
Property = @("Name", "Id", "ItemPath", @{Label="Locked by"; Expression={$_.Locking.GetOwner() } })
Title = "Items with lock reassigned"
InfoTitle = "Items with lock reassigned"
InfoDescription = "Items with the lock set '$($userLockOwner)' have been transferred to $($userNewLockOwner)."
$items = Get-Item -Path "master:" -Query "/sitecore//*[@__lock!='' and @__lock!='<r />']"
$items | ForEach-Object {
$PSItem."__Lock" = $PSItem."__Lock".Replace("$userLockOwner","$userNewLockOwner")
} | Show-ListView @reportProperties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.