Sitecore Powershell script to unlock all locked items in Sitecore
This post provides Sitecore PowerShell script to unlock all items locked in Sitecore by content authors.
If you are looking for a way to unlock all the items which are locked in Sitecore then here is the solution. This PowerShell script goes through all the items under a root node and unlocks them if they are locked.
Is this not the script you are looking for? Then check the complete list of Sitecore Powershell scripts
Sitecore Powershell script to unlock all locked items
$sourcePath = "/sitecore/content/Site1/Home"
function RunScript
{
$items = Get-ChildItem -Path $sourcePath -Recurse
$rootItem = Get-Item -Path $sourcePath
$items = $items + $rootItem
foreach ($item in $items)
{
foreach ($version in $item.Versions.GetVersions($true))
{
if($version.Locking.IsLocked())
{
$version.Editing.BeginEdit();
$version.Locking.Unlock();
$version.Editing.EndEdit();
Write-Host "Item un-locked:" $item.ID $version.Language;
}
}
}
}
$items = RunScript