Writing a script to allow editors to unlock an item locked by another user I used
New-UsingBlock(New-Object -TypeName "Sitecore.SecurityModel.SecurityDisabler"){
$item | Unlock-Item
}
This didn't raise errors, but didn't unlock the item
Directly calling the Unlock() method did work though
New-UsingBlock(New-Object -TypeName "Sitecore.SecurityModel.SecurityDisabler"){
$item.Locking.Unlock()
}
Is there a reason for this?
Note: this is only the briefest of outline, other possible differences include retrieving the item to unlock inside or outside the security disabler block, and getting multiple items (using a foreach-object for unlocking by second method, piping the results of the query using the first).
-PassThru
to unlock command, if data is returned then it's not exiting on the security check. Second, try user switcher.