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?
First the foundations:
- Create an application in SCCM that requires approval and publish it on the app portal
- Ensure that your mid server will execute powershell scripts (have a look here)
- 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:
- A scripted web service in ServiceNow that will create catalog item requests
- A new table in ServiceNow to keep track off the approval requests already created
- A Powershell script that
- connects to SCCM and collects pending approval requests
- Creates catalog item requests in ServiceNow via the rest interface
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
- Go to “Scripted rest APIs” in the left menu
- Create new
- Name it: “SC – create requested item”
- Give it an API ID – “sc_create_requested_item” (if you want it to play well with the scripts I’ll provide shortly)
- Save it but stay on the form
- In the resources related list click New
- Name it: “Create Requested Item”
- HTTP method is Post
- Save your new rest web service
Step 2 – New table in ServiceNow
Create a table with the following fields:
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:
- Connect to SCCM and get all pending Approval Requests (a wmi query)
- 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
- Compare the two data sets and find out what new requests to create in ServiceNow
- 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:
- a workflow that will handle the approval
- data in the table we have created
- updates back into SCCM
- 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 🙂