Required Deployment Failures using Orchestrator

This article is part of an ongoing series on how to use Orchestrator and CM 2012 together. For more articles, please go to

I have been trying to come up with a way to receive an automated email detailing devices with failed required deployments. This runbook accomplishes this goal. In order to complete it, you will need the CM 2012 Orchestrator integration pack (available here: and Data Manipulation integration pack (available here:


This runbook uses a WMI query to pick up all required deployments in your environment. It then uses the “Get Deployment Status” activity from the CM 2012 integration pack to look at the deployments and determine what computers failed to install the application. Finally, it sends an email with a list of those computers.


This is a fairly simple runbook, and should not take very long to create. This runbook only works for Applications and does not work for Packages.

Find Required Deployments

This step runs a WMI query against the SMS_ApplicationAssignment class. There is a property called OfferTypeID within this class that is set to “0” if the deployment is required and “2” if the deployment is available.

To create this activity, drag a “Run .NET Script” activity into your runbook (located under the “System” node). Double-click it to open it and click on the “General” tab to name the activity. Next, select the “Details” node and change the language type to PowerShell. Paste this code into the “Script” box:


$assignments = Get-WmiObject -ComputerName <CM
2012 primary site server> -Namespace root/SMS/site_ <CM
2012 site code> SMS_ApplicationAssignment | Where-Object -FilterScript {$_.OfferTypeID -eq “0”}

ForEach ($assignment in $assignments) {
$idint = $assignment.AssignmentID
$id = “$idint”
$name = $assignment.ApplicationName

$a += $id + “%” + $name

Be sure to replace the text in blue with the actual FQDN of your primary site server and your site code. The first thing this code is doing is establishing an array. We need an array so that Orchestrator executes the rest of the runbook for each required deployment. Next, we are running the WMI query that pulls all deployments that are required. Finally, the ForEach statement processes each required deployment and pulls out the ApplicationName (to be used in the email) and the AssignmentID. The AssignmentID in this case cannot be the same across multiple deployments. It serves as sort-of a primary key for assignments. The ID is being set in two variables here because its data type is Integer, and to combine it with the name in array it must be a String value.

I am combining the name and ID so that I only have one array running and the name moves with the ID. I will split the two back out in the next activity. I am using a percent sign to separate them because I do not have that symbol in any application name, and I can use whatever character I want in the next step to split the field. You can use whatever character you want here to separate your fields.

Finally, we must publish the array. To do this, select the “Published Data” node, and click the “Add” button. Complete the box like this:


Split Fields

Next, we need to split the ID and the name apart. To do this, add a “Split Fields” activity (located under the “Data Manipulation” node). When you open the activity, insert the Published Data from the previous activity into the “Input String” field and change the “Split Delimiter” field to whatever you chose for your split character.


To insert the Published Data in the input string field, right-click in the box, select “Subscribe”, and then “Published Data”.

Get Deployment Status

Next, add the “Get Deployment Status” activity (located under the “SC 2012 Configuration Manager” node). If you have not set up the connection to your CM 2012 environment, follow these instructions: Select the connection in the top box, then select “Application” in the second box.

Now we need to set up the filters so that we only look at required applications and only pull data on those devices that failed. To do this, click the “Add” button. In the “Name” box, select “AssignmentID” and keep “Relation” set to equals. In the value box, add the published data from the “Spilt Fields” activity. If you kept everything the way I have it, the AssignmentID should be Field01. Your box should look like this:


Next, we need to add the filter for ComplianceState. When this field equals “1”, the deployment was successful. When it equals “2”, it failed. We are only interested in devices that failed, so we can filter for that. Add another filter, and set the settings like this:


When you click OK on the “Filter Settings” box, your “Get Deployment Status Properties” window should look like this:


When the activity outputs its data, it does it as an array. If we kept the output as array, we would get a separate email for every computer that failed. To fix this so that we get an email per deployment and not per computer, select the “Run Behavior” node and check the “Flatten” check box. Next, select the button on how you want the output to be configured. I prefer to separate the device names using line breaks, but you can format it however you want.


Send Email

Finally, add the “Send Email” activity to your runbook (located under the “Email” node). In the subject box, add what you want the subject to say. Mine is called “Failed Deployment List – {Field02 from “Split Fields”}. The Published Data that I added is the application name from the “Split Fields” activity. This allows me to differentiate the deployments if I multiple going out at the same time. Again, if you set everything up the same way I have, the application name should be in Field02.

Next, add the Published Data for MachineName in the message box. It should look like this: {MachineName from “Get Deployment Status”}. This is part of the published data in the “Get Deployment Status” step. It will only add the device names that meet our two filter criteria. After these fields are filled out, the windows should look like this:


The only thing missing are recipients. Click the “Add” button to add them.

Next, configure the outgoing server settings in the “Connect” node. Fill them out according to your organization’s settings.

I hope this helps you evaluate your deployments a little easier. Please continue to check back for more Orchestrator runbooks to simplify your CM 2012 environment.



Contact Us

On Key

More Posts

Mastering Azure AD Connect - A Comprehensive Guide by WME
Active Directory

Mastering Azure AD Connect – A Comprehensive Guide

Modern businesses are fast moving toward cloud-based infrastructure. In fact, cloud-based business is not just a trend anymore but a strategic necessity. Microsoft’s Azure Active Directory (Azure AD) has become a frontrunner in this domain. It

Read More »
Security Best Practices in SharePoint
Office 365

Security Best Practices in SharePoint

Microsoft SharePoint is an online collaboration platform that integrates with Microsoft Office. You can use it to store, organize, share, and access information online. SharePoint enables collaboration and content management and ultimately allows your teams to

Read More »
The Ultimate Guide to Microsoft Intune - Article by WME
Active Directory

The Ultimate Guide to Microsoft Intune

The corporate world is evolving fast. And with that, mobile devices are spreading everywhere. As we venture into the year 2024, they have already claimed a substantial 55% share of the total corporate device ecosystem. You

Read More »
Protecting Microsoft 365 from on-Premises Attacks
Cloud Security

How to Protect Microsoft 365 from On-Premises Attacks?

Microsoft 365 is diverse enough to enrich the capabilities of many types of private businesses. It complements users, applications, networks, devices, and whatnot. However, Microsoft 365 cybersecurity is often compromised and there are countless ways that

Read More »
Be assured of everything

Get WME Services

Stay ahead of the competition with our Professional IT offerings.