SCCM application approval requests in ServiceNow

WELCOME – This is the very first post on my site. It will explain how to build an integration between SCCM and ServiceNow that allows ServiceNow to handle approval requests going into SCCM via the SCCM Application Portal.

To limit the length of the post I’ll split it into a few posts – this is the first.

The Problem being solved:

SCCM does not include a workflow engine to support the approval request process! Why is this a problem? Well it lead to an unstructured and random approval process when ordering new software packages for installation. Applications being distributed via SCCM can be configured to require approval before installation. If users are used to go to the application portal and request applications the approval request spawned are going into SCCM. SCCM is very limited in this area and basically it is up to someone with access to SCCM to approve the request. ServiceNow on the other hand, has very rich workflow functionality – so how about letting the approval process go through ServiceNow?

The overall flow:
flow

First the foundations:

  1. Create an application in SCCM that requires approval and publish it on the app portal
  2. Ensure that your mid server will execute powershell scripts (have a look here)
  3. Install the latest Powershell version – I’m using classes and that is only supported in version 5.0 and onwards (this will execute on the mid server)

With the foundations in place let’s try to build the functionality that will take pending approval requests from SCCM and create catalog item requests in ServiceNow.

For that you need:

  1. A scripted web service in ServiceNow that will create catalog item requests
  2. A new table in ServiceNow to keep track off the approval requests already created
  3. A Powershell script that
    1. connects to SCCM and collects pending approval requests
    2. Creates catalog item requests in ServiceNow via the rest interface
  4. A javascript that will tell the ServiceNow mid server to execute the powershell script created in step 3

Disclaimer – This code snippets below are only meant as a starting point. Add logging and proper error handling before doing anything production related with it 🙂

Step 1 – scripted web service:

First – for an introduction to this functionality have a look here

  1. Go to “Scripted rest APIs” in the left menu
  2. Create new
  3. Name it: “SC – create requested item”
  4. Give it an API ID – “sc_create_requested_item” (if you want it to play well with the scripts I’ll provide shortly)
  5. Save it but stay on the form
  6. In the resources related list click New
  7. Name it: “Create Requested Item”
  8. HTTP method is Post
  9. In the script section post this javascript snippet:
  10. Save your new rest web service

Step 2 – New table in ServiceNow

Create a table with the following fields:

table

Ensure that Approval state and state are choice types.

State will have the following choices: Pending Approval, Completed and Closed

Approval State will have the following choices: Approved and Rejected

Step 3 – Powershell script

The Powershell scripts will do the following:

  1. Connect to SCCM and get all pending Approval Requests (a wmi query)
  2. Connect to ServiceNow and collect approval requests that have been created already (we don’t want to create the same request twice)
    This is the table created in step 2 that we will query via the rest web service API
  3. Compare the two data sets and find out what new requests to create in ServiceNow
  4. Create the new requests in ServiceNow via the scripted rest web service created in step 1

Script #1 – This is what you will call from ServiceNow via the mid server

Script #2 – the module used to create a class

With this in place you have the functionality that will take pending requests from SCCM and create catalog item requests in ServiceNow. You have a table that is used to keep track of the requests, but you still miss:

  1. a workflow that will handle the approval
  2. data in the table we have created
  3. updates back into SCCM
  4. A scheduled job in ServiceNow that kicks it all off

I’ll cover that in my follow-up post.

Drop a comment if you have something to say 🙂