PowerShell – Unlock objects in SCCM

Well most of us have seen it. Someone opens an application, package or tasksequence and then leaves the computer behind or the console crashes just when you where about to make the final change.

The object is now locked for editing by either you or someone else and rebooting the server aint helping.

Well there is help to be had. There are two ways to fix this.
– The old way, database editing. You go in to SQL manager, open the database select the table and update entries within it.
The problem with this way is its not supported to directly change anything in the database.

– The new way, powershell to the rescue.
There is a cmdlet to that is called unlock-cmobject. But then you need to connect to the ps site and figure out wich object to unlock.

I’ve run into this a couple of times and each time is a Learning process to remember how to unlock it again.

So now i’ve made a small script to help you out. All you really need is the site code of your sccm site and the name of the object you want to unlock. Doesn’t matter if its a application, a package, a operatingsystem image, a task sequence, a boot image or a driver package it works for all of them.

The one thing you either need to change or type everytime (unless you have installed your console to D:\) is the path to the configmgr powershell module. It can be found in your installation dir\adminconsole\bin\ConfigurationManager.psd1

Its one of the top lines in the script and feel free to change it to fit your env. otherwise running the script with -importmodule “path\path\ConfigurationManager.psd1” will aslo work.

Apart from that the script is run by running .\unlock-sccmobject -cmsitecode “sitecodehere” -object “name of object you want to unlock”
for example .\unlock-sccmobject -cmsitecode ps1 -object “SQL Server 2008 R2 SP2 Managment Studio”

unlock-sccmobject

Script can be downloaded here. http://1drv.ms/VCbThg

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s