Summary

Removing the lock on an object in SCCM using PowerShell.

Issue

When using ConfigMgr you will at some point come across the following error:

PowerShell_UnlockCMObject_Error_27032015

This occurs when an object does not have its lock flag removed upon closing (managed by the Serialized Editing of Distributed Objects mechanism), this could occur because you have logged into ConfigMgr using multiple consoles or if the interface simply has crashed and the lock was not removed.

Resolution

You can wait 30 minutes for the lock to expire and you *should* have access to the object again.

Alternatively as in SCCM 2007 you could run a database expression to remove the lock from the object directly in the database.

  1. Log on to the SQL Server holding your SCCM database using Microsoft SQL Server Management Studio
  2. Run a New Query
    – Right click your CM Database
    – Click New Query
    PowerShell_UnlockCMObject_NewQuery_27032015
  3. Find the LockID for the object you are trying to delete by running the following query
    SELECT * FROM SEDO_LockState WHERE LockStateID <> 0

    This will display ID’s of all items locked, locate the relevant user and note the LOCKID
    PowerShell_UnlockCMObject_Search_27032015

  4. Delete the lock using the following expression
    DELETE FROM SEDO_LockState WHERE LockID = ‘<LockID from step 3>’

    PowerShell_UnlockCMObject_Delete_27032015

This however is not a supported practice.

The better way is to use a PowerShell commandlet included in PowerShell toolset

Unlock-CMObject

Implementation

Usage of the commandlet is very simple

Unlock-CMObject -InputObject $(Get-CMApplication -Name '<application name>')

In our example the

Unlock-CMObject -InputObject $(Get-CMApplication -Name 'Mozilla Firefox 30')

PowerShell_UnlockCMObject_PowerShellUnlock_27032015

To get a full list of options, as with all Microsoft commandlets simply type

get-help Unlock-CMObject -Full