Last active
June 10, 2018 10:49
-
-
Save michaellwest/d375c8814fdd850c275f3a834a1010f2 to your computer and use it in GitHub Desktop.
Transfer lock ownership from one user to another using Sitecore PowerShell Extensions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Find all items locked by a specific user and transfer to another user. | |
.DESCRIPTION | |
This report helps identify all of the items locked by a user and transfers to another user. | |
.NOTES | |
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") { | |
Exit | |
} | |
$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") | |
$PSItem | |
} | Show-ListView @reportProperties | |
Close-Window |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment