Deploying an Application Using Orchestrator

Orchestrator can automate many tasks for you. One of its major features it its ability to integrate with other System Center products. In this article, I will show how you can deploy an application to a group of computers using a runbook. I will demonstrate how to do this with only a text file with a list of computers. This is meant to be a starting point, and can be adapted to meet your organization’s needs.

In order to complete this article, you will need the CM 2012 integration pack for Orchestrator. It can be downloaded here: http://www.microsoft.com/en-us/download/details.aspx?id=28725. This download includes all of the integration packs for System Center 2012.

Runbook Overview

1

This is generally what your runbook will look like. I will go over each step in detail later. To begin, we will tell the runbook what application we want to deploy. This can either be set to the application name or it’s ID. Next, we will create the collection based off the application name given. Next, we will find the current date and time and add two hours to it. Next, we will deploy the application as required. Then, we will import a list of the computers that we want the application deployed too. Finally, we will add the computers to the collection.

Now, why are we deploying the application before we add the computers to the collection? The “Import Computers” activity imports a list of machines as an array. Orchestrator handles arrays by splitting the runbook into individual processes for each item in the array. We only want to create the collection and deploy the application once, instead of many times. Given the speed at which runbooks execute, there should not be problem with a client missing a deployment.

Initialize Data

To begin, we need to tell the runbook what application we want to deploy. We can do that using the “Initialize Data” activity.

2

Simply drag the activity into your runbook (it is located under the “Runbook Control” section) and double click on it. Click the add button, and give your field a name.

Create Collection

Next, drag the “Create Collection” activity into your runbook (located under the “SC 2012 Configuration Manager” section). Double-click on it, and fill it out like mine:

3

The “Connection” box is configured by clicking on “Options” in the toolbar, then “SC 2012 Configuration Manager”. This is where you tell Orchestrator your server for your CM 2012 environment.

In the “Collection Name” field, I have inserted the published data provided by the “Initialize Data” activity. I also added “-deployment” to the end, just in case I already have a collection named like my application. You can do this if needed, or change it as needed.

I limited my collection to “All Systems”. This, of course, is another option you can change as needed.

Find Date

The scheduled-start date and installation deadline dates are both required in the “Deploy Application” step. I used PowerShell to get these values. To do this, drag a “Run .NET Script” activity into your runbook (located under the “System” node). Change the “Language” box to Powershell, and paste this code into the “Script” box:

$date = get-date $startdate = $date.tostring(“yyyy-MM-ddThh:mm:ss”)

$date2 = $date.AddHours(2) $enddate = $date2.tostring(“yyyy-MM-ddThh:mm:ss”)

This code is grabbing the current date and time and converting it into the correct format. Next, it is adding two hours to the current date and time. It stores both of these as variables that we will need in the next step. I added two hours to mine because I do not have any applications that take over two hours to install. This can be adjusted as needed in your environment.

Because this is a script, we must publish the data. To do this, click on the “Published Data” node add two values like this:

4

5

Deploy Application

Next, drag the “Deploy Application” activity into your runbook (located under “SC 2012 Configuration Manager”). Assign the correct configuration item just as we did in the “Create Collection” activity. Next, fill in the fields as shown:

6

7

The values in “Deployment name”, “Application”, “Collection”, “Schedule Availability”, and “Installation Deadline” are all published data from previous steps. The value in “Application” is particularly important. It is vital that you enter a valid application name in this field, if you do not, the runbook will fail at this step. The application name is the “Name” field when you create your application.

I left the distribution point options blank in my example because all of my applications are pre-deployed to my DP’s. You can set these options as needed.

I would also encourage you to look at the additional fields by clicking on the “Optional Fields” button. There may be more in there to assist your deployments.

Import Computers

This activity imports a text file of computer names to add to the collection. This text file is simply list of computer names on different lines. This file must be stored on a file share that the Orchestrator service account as access too (or on your Orchestrator server).

This activity, like the “Find Date” activity, is a PowerShell script. Add a “Run .NET Script” activity to your runbook and change the language to PowerShell. Paste this code into the script box:

$a = @()

$comps = get-content \deployment.txt

ForEach ($comp in $comps) { $a += $comp }

As mentioned before, this script reads the file and puts the computer names into an array. We need to publish the array to the next step by adding this published data:

8

Add Collection Rule

Finally, drag the “Add Collection Rule” activity into your runbook. Set the connection as we did in the “Create Collection” and “Deploy Application” step. Next, set the fields like this:

9

Again, the “Collection”, “Rule Name”, and “Rule Definition” fields are all published data from previous activities. I used a direct rule because I knew the computers I wanted to deploy too. You can also do a query rule if you want to base collection membership (and software deployment) on any sort of CM 2012 collection query.

Summary

This is quick way to manage your software deployments using Orchestrator. The best part about this is that now I can use the Orchestration Web Console to push software without the CM 2012 console. The “Deploy Application” step can also be easily switched out for “Deploy Program” or “Deploy Task Sequence”, making your deployments available from anywhere you have a Silverlight-enabled web browser.

Come back in the next few weeks for more CM 2012 and Orchestrator runbooks.

email

Written by , Posted .
  • dride

    This is very good. Thanks!