Working with a parameter of GUID type to set Actual End Date for Change Requests
In this post I wrote how to manage GUID type of the script parameters. Now I want to present an example of such a scripts. Some of SCSM 2012 customers have noticed that ‘Actual End Time’ field of Change Requests is not being populated in the last version of Microsoft System Center 2012 Service Manager. I don’t know why the vendor has removed this workflow but sometimes this field is required in reports to assess the average (max, min) durations of different types of the change requests.
So we know that Actual End Time field exists and remains empty. First of all, we prepare a short script that will be executed when the status of the change request is set to “Closed”. We will make Actual End Time equal to Last Modified because we expect that our workflow won’t be started immediately after closing of the change request and the value of Last Modified will be closer to the actual moment.
Here is the script. It uses SMlets and is prepared for Service Manager Authoring Tool. Please note that $ChangeGUID is a parameter that refers to ‘ID (Internal)’ in the terms of the Authoring Tool.
#--------Load SMlets-----------------
$a= (get-module|%{$_.name}) -join" "
if(!$a.Contains("SMLets")){Import-Module SMLets -ErrorVariable err -Force}
#--------- Set ActualEndDate to LastModified --------------------
$change = Get-SCSMObject -Id ([guid]$ChangeGUID).ToString()
$t = $change.LastModified.ToUniversalTime()
Set-SCSMObject -SMObject $change -Property ActualEndDate -Value $t
#--------Unload SMlets-----------------
remove-module -name SMLets –force
You can find Authoring Tool project by the link below. Use it ‘as is’ or change in the way you like.
The solution requires installed SMlets as usual.
Good luck with SCSM customizing!