- Glen (Xapity)
PowerShell for SCSM: Software Request Example
Software Requests are a very common feature of most self-service portals using SCSM. In this example we will use Xapity PowerShell and Xapity Notification Activities to implement a Software Request solution that does not use Orchestrator or any custom workflows.
We also created a video that gives an overview of the process that can be viewed below.
The solution builds on the other PowerShell Scripting posts that we have done and they should be referenced when more detail is required.
Step 1: SR template
Create a Service Request Template for Software Requests. This has two PowerShell Scripts that are explained below. It contains a Review Activity for the Approver that was selected on the Portal. And includes a Notification Activity to email the affected user at the end of the process with a software guide.
In some cases we have created a Service Request template for each software item and then created individual Request Offerings for each software item. This can give more control and allow more customization for each software request. In this example we are trying to make it generic and allow it to scale without too much work, so we will created one generic Software Request Template.
Step 2: Create the Request Offering
The solution example on the Self Service Portal uses a simple request offering , basically a simple list of the software available and then a user query where they can select the approver for the software.
The software selected is mapped to a Service Request custom extended property "SRstring". This makes it easier to reference and make decisions on the software selected. If you wanted to build up the solution further, you could look at this being a software CI or possibly a business service.
The approver from the portal is stored as a relationship against the Review Activity rather than the Service Request. In the PowerShell script we can then use this relationship to retrieve the user details and add them as the reviewer. The image below shows where to set the user object is related to the Review Activity.
PowerShell: Portal Software Request - Script 1
This script updates the title field of the Service Request and the Review Activity to show what software was chosen. The script then adds the selected approver from the portal as the Reviewer on the Review Activity.
As we are using the Xapity PowerShell Activity the $ParentID variable has already been defined by the activity and we can use it in the script without declaring it.
The script retrieves all the activities on the SR with a filter for only Review Activities. I am using activity work item tags as outlined in our blog http://www.xapity.com/single-post/2016/10/23/PowerShell-Scripting-for-SCSM-Work-Item-tags to identify which review activity I need to update.
The script then updates the RA title. It sets the options for the reviewer - must vote and veto. It uses the relationship created in the Request Offering to get the SoftwareApprover and then sets this as the Reviewer on the activity.
At the end of the script it adds an Action comment to the Service Request Action Log (refer to http://www.xapity.com/single-post/2016/11/27/PowerShell-for-SCSM-Updating-the-Action-Log ).
PowerShell: Portal Software Request - Script 2
Script 2 runs after the Approval has been granted. It will add the relevant software guide to the Notification Activity and add the affected user to the Software Deployment Group for SCCM to deploy the software.
It retrieves the activities on the Service Request with a filter for Xapity Notification Activity. I have not extended the Notification Activity to support work item tags, so instead am using a keywords in the title.
Adding the Software guides relies on the list on the portal matching the folder name. It would be useful to add some verification and error control at this point in case the folder does not exist or there were typo's made.
The script lops through each of the files in the folder. It reads each file into memory, then creates a new attachment item in SCSM and then commits the new object to Service manager using the type projection method.
It adds an Action comment to the Service Request action log to record what files were uploaded.
And finally it adds the user to the software deployment group with another action log comment to record the action.
Download these scripts: SoftwareRequestExample.zip
Full Script: Portal Software Request - Script 1
Full Script: Portal Software Request - Script 2
See this solution in action:
Xapity - Innovative Software for SCSM - Discover our Products
#PowerShell #Portal #SCSM #PowerShellActivity #NotificationActivity