Removing the lock on an object in SCCM using PowerShell.
When using ConfigMgr you will at some point come across the following error:
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.
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.
- Log on to the SQL Server holding your SCCM database using Microsoft SQL Server Management Studio
- Run a New Query
– Right click your CM Database
– Click New Query
- Find the LockID for the object you are trying to delete by running the following query
SELECT * FROM SEDO_LockState WHERE LockStateID <> 0
- Delete the lock using the following expression
DELETE FROM SEDO_LockState WHERE LockID = ‘<LockID from step 3>’
This however is not a supported practice.
The better way is to use a PowerShell commandlet included in PowerShell toolset
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')
To get a full list of options, as with all Microsoft commandlets simply type
get-help Unlock-CMObject -Full