Wednesday, September 4, 2013

Sitecore PowerShell Extensions Unlock Items

Below is an example of how to unlock all items under the Content tree.
 
# Find all the items under content recursively, then only return the properties you want. Here we only want items that are locked.
gci master:\content -rec | where { $_.Locking.IsLocked() } | 
    select Name, Id, @{n="IsLocked";e={$_.Locking.IsLocked()}}
 

The following aliases or shortened commands were used:
  • gci = Get-ChildItem
  • where = Where-Object
  • select = Select-Object
Note: To autosize the table pipe the output to the following command: ft -auto
 
# Unlock all the items.
gci master:\content -rec | where { $_.Locking.IsLocked() } | % { $_.Locking.Unlock() }