Sitecore Powershell script to unlock all locked items in Sitecore

Pranay    20 Mai '19    113 views

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

Unlock Items PowerShell

About the author

Pranay Deegoju
Sitecore Certified Professional

A Software Engineer by profession, a part time blogger and an enthusiast programmer. You can find more about me here.



Leave your comments on this post here


Want more such posts, subscribe here

Recent Posts

×

Liked this article?

Subscribe with your email and get updates when ever a new article is posted.

By subscribing you agree to our privacy terms. We promise that we do not sell your data.