31 December 2012

Orchestrator vs Powershell … I win!

 

Wow! it has been a long time since I last blog on my findings. I made a vow to be more active in 2013 in the blogging world so that I can share my System Center experience with the folks out there.

Now, lets get straight to the point. One of the biggest news (at least for me) with System Center Configuration Manager 2012 SP1 is the fact that it now has Powershell cmdlets that let you automate and scripts CM tasks. In short, this got me more excited than SCCM 2012 itself!

Well, Orchestrator does have it’s own capabilities to automate CM tasks via the Integration Pack for SCCM 2012. Nevertheless, as much as I like the Activities made available through the Integration Pack, there are still some functionalities which is missing. For example, there isn’t any activity for Delete CM Deployment.

In order to do that, I have decided to use Powershell scripts to automate that. You can view the cmdlets reference from MyITForum

http://myitforum.com/myitforumwp/2012/12/03/powershell-and-configmgr-list-configmgr-cmdlets/

Now, one should note that the SCCM cmdlets only runs on Powershell 3.0. If you are running Windows Server 2012, you are good to go.

Unfortunately, good old Orchestrator will give you problems if you thought of using “Run .NET Script” because by default it will load the Powershell 2.0 which will fail when you import the SCCM module

To resolve this, we need to “force” Orchestrator to run the Powershell scripts on Powershell 3.0.

How do you do this?

Well, I call it calling a “Powershell from a Powershell approach” where we encapsulate our powershell scripts in another powershell command.

eg: If let say our Powershell script is

Import-Module “C:\Program Files (x86)\Microsoft Configuration …..

CD RDY:

Remove-CMDeployment …….

 

We just need to do this

Powershell {

Import-Module “C:\Program Files (x86)\Microsoft Configuration …..

CD RDY:

Remove-CMDeployment …….

}

Now you are ready to go.

image