Month: August 2014

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

PowerShell – ActiveDirectory Batch users

So we got a Project around the corner where we need to create a bundle of new users.
So I made a small powershell script to help me to just that. And I know there is alot of them already out there but I can never seem to find on that does what I want when I need it so i just made my own.

Script and csv file for the user info can be downloaded herehttp://1drv.ms/1Bj3m3S

Powershell – VCRedist automagic

So a good friend of mine Mikael Nystr̦m wrote this awesome script about Always needing the VC++ Redist editions for when he makes reference images. The post can be read in full here http://deploymentbunny.com РPowershell is king.

That got me to thinking since we all build our ref images in MDT anyway and MDT is powershell based would it be possible to download the needed files, import them as applications and cleanup the downloaded files after. Well as you might have guess yes you can.

I’ve shamlessly copied mikes nice script and added some features so you can Point to your deploymentshare and choose if you want to cleanup after the download and import is done.

Updates script file and xml file can be downloaded from here Script files

Feel free to checkout the script and if you have already tried Mikes script there are 3 new paramters that can be set
– MDTPowershell, this needs to Point to the powershell commandfile that mdt has (no need to use this if your mdt application installation is in the default Place

– MDTRoot, this needs to be set to the deploymentshare where you want the applications imported. Default is C:\DeploymentShare

-CleanUp, This is by default False and can be set to true in wich case it removes all the downloaded files at the end of the script.

As a last note the XML file has been updateded with a new value that for each application/file that is beeing downloaded there is a section called <MDTCommandLine> this should contain any commandline switches that is needed to make the application install silently.

Do Enjoy