This is a guest blog post by Mark Newton, one of our community contributors. Thanks for sharing Mark!
========================================
I have set up a number of ‘Service Requests’ in SCSM 2012 which are all working great. However what we were finding was that all our requests once finished were in the SCSM console with a status of ‘Completed’. We were having to go in periodically and ‘Close’ all the request so that they will be eventually purged from the console. I thought what a simple job for Orchestrator to do and here is how I set it up.
This is what the run book looks like:
1. Monitor Date/Time is just setting what time do I want the run book to check for completed service requests.
2. -7 days is essentially saying check 7 days back.
3. Get Completed SRF gets service requests which are ‘Completed’ and older than 7 days using the information available on the bus from –7 days.
4. On the line between Get Completed SRF and Close SRF is ‘Only if value > 0’. This ensures that the next step is only carried out if there are service requests which have completed.
5. Close SRF closes the service request, sets a closed date and adds a description.
Travis: Cool! Hey is this doable in the Authoring tool workflow generator?
Thanks Travis and Mark! Let me share a solution for Greg and the community. Below a script in powershell. It uses native Service Manager commandlets so it's easy to add in Authoring Tool. Here you are:
CD 'C:\Program Files\Microsoft System Center 2012\Service Manager\Powershell'
Import-Module .\System.Center.Service.Manager.psd1
$SomeDaysOld = (get-date).adddays(-7)
$UNC_Now = (get-date).ToUniversalTime()
$IncidentClass = Get-SCClass -Name System.workitem.incident
$Inc_resolved = Get-SCClassInstance -Class $IncidentClass -Filter "Status -eq IncidentStatusEnum.Resolved" | ?{$_.ResolvedDate -lt $SomeDaysOld}
If ($Inc_resolved -ne $null)
{
foreach ($Inc in $Inc_resolved)
$Inc.Status = "bd0ae7c4-3315-2eb3-7933-82dfc482dbaf"
$Inc.ClosedDate = $UNC_Now
Update-SCClassInstance -Instance $Inc
}
$SRclass = Get-SCClass -Name System.WorkItem.ServiceRequest
$SR_completed = Get-SCClassInstance -Class $SRclass -Filter "Status -eq ServiceRequestStatusEnum.Completed" | ?{$_.CompletedDate -lt $SomeDaysOld}
$SR_failed = Get-SCClassInstance -Class $SRclass -Filter "Status -eq ServiceRequestStatusEnum.Failed" | ?{$_.CompletedDate -lt $SomeDaysOld}
$SR_cancelled = Get-SCClassInstance -Class $SRclass -Filter "Status -eq ServiceRequestStatusEnum.Canceled" | ?{$_.CompletedDate -lt $SomeDaysOld}
If ($SR_completed -ne $null)
foreach ($SR in $SR_completed)
$SR.Status = "c7b65747-f99e-c108-1e17-3c1062138fc4"
$SR.ClosedDate = $UNC_Now
Update-SCClassInstance -Instance $SR
If ($SR_failed -ne $null)
foreach ($SR in $SR_failed)
If ($SR_cancelled -ne $null)
foreach ($SR in $SR_cancelled)
Remove-Module System.Center.Service.Manager
m getting an error SC Object GUID null or empty. when i run my runbook i’m asked to give the Acticity ID. I am giving the ID which i have at my runbook in console i.e. 81fba1eeee054d89bf5c78aec05e0de4
Till second steps it works then at get relationship it give the error
@Greg - Refer to this post dynamicdatacenter.wordpress.com/.../auto-close-resolved-incidents for an alternative method in the Authoring Tool.
I've got the same issue as Saniya - Get Object is returning a null/empty value.
i want to create a custom workflow which will change service request status to IN PROGRESS when assign to someone.
if any one share powershell script