scsm custom postpone activity

by Nathan

(Hopefully) Useful Information on Microsoft System Center, Hyper-V and Cloud

Previous Post
Next Post
David Allen
SCSM – Custom Postpone Activity

Posted on July 31, 2015

A number of requests I have had of late have been to build in a time delay into the workflow of a service request in SCSM.  An example of this was building a server de-provisioning workflow, which needed to have a two week delay between powering off the server, and completely deleting it.  The workflow I put together for this involved Orchestrator runbooks to perform tasks such as removing System Center agents and powering down the server, however I did not want an Orchestrator runbook to be running for two weeks before the server deletion could be performed.

To solve this problem, I used a runbook activity within the Server De-Provisioning service request to generate a new service request for Server Deletion, based on a template that I had already created.  This means the original de-provision service request will complete successfully, with all tasks completed except the server deletion, which will now be performed under the new service request.

Unfortunately, this still left the issue that I needed a delay of two weeks before I could initiate a runbook activity to delete the server.  So, after putting my thinking cap on, I came up with this solution, which may not be the best, so if anyone has a better solution, please let me know…


The Solution

In order to achieve the two week delay I performed the following actions to build a new management pack in the Service Manager Authoring Tool:

1.  Created a new class based on the Activity class.  I could have used an existing activity class, such as manual activity, but I wanted to make it clear what this activity was in the workflow, and to make it easily identifiable later in the workflow.


2.  Create a scheduled workflow that looks for all instances of the PostponeActivity class that are In Progress, and complete the tasks if the End Date has passed.  In this case, the scheduled workflow is triggered every 12 hours and runs a PowerShell script to assess the End Date with the current date, and change the status to Completed if the End Date is in the past.



The PowerShell code in the script activity is:

Postpone Activity

$a = (get-module|%{$}) -join ” ”

if(!$a.Contains(“System.Center.Service.Manager”)) {Import-Module “D:\Program Files\Microsoft System Center 2012 R2\Service Manager\PowerShell\System.Center.Service.Manager.psd1” -ErrorVariable err -Force}

$Class = Get-SCSMClass -Name PostponeActivity
$Instances = Get-SCSMClassInstance -Class $Class -Filter “Status -eq In Progress”
$Date = (Get-Date).ToShortDateString()

ForEach ($Instance in $Instances) {
  $DeletionDate = ($Instance.ScheduledEndDate).ToShortDateString()
  If ($Date -ge $DeletionDate) {
    $Instance.Status = “Completed”; $Instance | Update-SCSMClassInstance


3.  Saved and sealed the new management pack which will generate an MP and a DLL file, amongst others.  Import the MP file into the SCSM management group, and copy the DLL file to the workflow management server, and restart the Microsoft Monitoring Agent service.

4.  Once the MP is imported, create a PostponeActivity template based on the new class.  Other than providing a template name, nothing else is required in the template.


5.  With the template created, the Server Deletion service request I discussed earlier can be updated for the workflow to include the Postpone Activity.


6.  Now, the Scheduled End Date just needs to be set within the postpone activity that will provide the required delay, which in this scenario is 14 days.  Obviously the Scheduled End Date cannot be hard coded in the template as it’s always going to be different, so I set this date in the runbook that creates the Server Deletion service request.

7.  Wait for the PowerShell workflow to run after the Scheduled End Date has past, and watch the Postpone Activity automatically complete, allowing the next task in the workflow to run… In this workflow, that’s a runbook activity to delete the server.

That’s all there is to it ?


I appreciate this may seem slightly confusing, as I have not covered all the steps performed in the runbooks, but this should give you the information you need to achieve a similar result, and to help you along I have attached a sample management pack based on the above, which you can download from the TechNet Gallery, here.

And, I will post the full server de-provisioning process I put together very soon!


Share this:
Click to share on Twitter (Opens in new window)
Click to share on Facebook (Opens in new window)
Click to share on Google+ (Opens in new window)
Click to share on LinkedIn (Opens in new window)
Click to email this to a friend (Opens in new window)
Click to print (Opens in new window)
Share on Skype (Opens in new window)
Click to share on WhatsApp (Opens in new window)

Tags: Management Pack, SCSM, Workflow

Eric Krasner October 5, 2016

Great post, only one issue. In the PowerShell script for the workflow, using the .ToShortDateString() provides unreliable results. It works better just using .Date instead.

David Allen October 6, 2016

Thanks for the feedback… Much appreciated!

Ozge Ozkaya December 11, 2016

Dear David, when i follow your suggestions to create a custom class based on Activity class, i add this as a first activity onto a Service Request Template. And publish through an offering to the portal for the end users.. When i try to submit the SR, it fails with the below event log:

System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.EnterpriseManagement.ServiceManager.Applications.ServiceRequest.Common.UserInput.UserInputViewModel.FetchPropertyItem(Question question, String propertyPath)
at Microsoft.EnterpriseManagement.ServiceManager.Applications.ServiceRequest.Common.UserInput.UserInputViewModel.SetProjectionProperty(Question question, ManagementPackEntityPropertyTypes propertyType, String propertyPath, String propertyName)
at Microsoft.EnterpriseManagement.ServiceManager.Applications.ServiceRequest.Common.UserInput.UserInputViewModel.SetUserInputValues()
at Microsoft.EnterpriseManagement.ServiceManager.Applications.ServiceRequest.Common.UserInput.UserInputViewModel.ApplyValues()
at Microsoft.EnterpriseManagement.ServiceManager.Applications.ServiceRequest.Common.DataSourceHelper.ValidateUserInput(CompositeDataItemCollection dataItemCollection)……

David Allen May 26, 2017

That error suggests that there is in issue with the inputs for the offering…. Did you get it sorted in the end?

Leave a Reply

Notify me of follow-up comments by email.

Notify me of new posts by email.

Recent Posts
Azure Stack – Development Kit (Single Node)
Cireson Survey – Pre-Selecting The Satisfaction Slider
SCOM – Monitor SCSM Data Warehouse Jobs
SCOM – Updated Unsealed MP Backup Management Pack
Microsoft Azure – Securing Accounts With Access To The EA Portal
October 2017
September 2017
July 2017
November 2016
August 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
May 2015
February 2015
October 2014
September 2014
Azure Automation
Azure Stack
Configuration Manager
Data Protection Manager
Data Warehouse
Management Packs
Microsoft Azure
Operations Manager
Password Reset
SCU Europe
Service Manager
System Center
Visual Studio
Windows Azure Pack
Windows Server 2012 R2
Windows Server 2016
Automation Azure Backup Barcelona Cireson Cloud Compliance Containers Dashboard Data Warehouse DCM DPM Events Grooming Hyper-V Ignite iPad Library Sharing Log Shipping Management Pack MPSync MVP Performance PowerShell Remediation Reporting RSAT SCCM SCOM SCSM SCU SQL SquaredUp System Center System Center 2016 Tape TechEd Technical Preview Update Rollup VMM WAP Window Server Windows Server Windows Server 2016 Workflow
Useful Sites
Aquilaweb Cloud Solutions

© 2017 – Design by

Back to top