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"){

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).

  • Two things to try. Add -PassThru to unlock command, if data is returned then it's not exiting on the security check. Second, try user switcher. – Michael West Mar 16 '18 at 11:23
  • I'll try with -PassThru, but the second version of the code is working fine, so I'm mainly just curious. – James Walford Mar 16 '18 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.