Service Manager Convert Incident To Service Request Console Task

Service Manager konsolda açılmış herhangi bir Incident kaydını Service Request’e dönüştürme özelliği bulunmaktadır. Bu özellik Incident‘a ait Affected User, Title ve Description parametrelerini kopyalayarak Service Request kaydına aktarmaktadır ancak Incident kaydı açık kaldığından elle kapatılması gerekmektedir. Çağrı yoğunluğunun çok olduğu sistemler düşünüldüğünde Incident‘ın kapatılması unutulabilir ve de ekstra bir iş yükü doğurabilir.

Microsoft Technet’te yayınlanan script’i kullanarak bu işlemi nasıl kolaylaştıracağımızı göreceğiz.

Öncelikle Service Manager konsolunda Library/Tasks/Create Task diyerek bir Task oluşturuyoruz.

Task name: Create Service Request
Target class: Incident
Management pack: Yeni oluşturduğunuz MP

Categories: Incident Management Folder Tasks

Full path to command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Parameters:

powershell.exe -ExecutionPolicy unrestricted -WindowStyle Hidden -file \\scsm\SCSMTask\IRSR.ps1 "$Context/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Id$"

Working directory: %windir%\system32

Kaydedip Task işlemini sonlandıralım. Task işlemi hata verirse ID parametresini Insert Property butonuyla yeniden eklemeyi deneyelim. Yukarda da görüldüğü gibi PowerShell’in kontrol edeceği bir paylaşım içinde script olması gerekiyor. (\\scsm\SCSMTask\IRSR.ps1)

“C” altında “SCSMTask” adında bir paylaşım oluşturalım ve aşağıdaki kodu IRSR.ps1 uzantısı ile kaydederek paylaşımın içine kopyalayalım. 2. satırdaki Computer ismini kendi SCSM sunucu isminizle değiştirmeniz gerekmektedir.

$IncId = $args[0]
$Computer = "scsm server name (server.domain.com)"
Write-Host "Incident id is $incid"
Import-Module SMlets 
$IncClass = Get-SCSMClass -Computer $Computer -Name System.WorkItem.Incident$
$SRClass = Get-SCSMClass -Computer $Computer -Name System.WorkItem.ServiceRequest$
$FilterStr = "ID -eq " + $IncID
$Inc = Get-SCSMObject -Computer $Computer -Class $IncClass -Filter $FilterStr
if (($Inc -ne $Null) -and ($Inc.Status.DisplayName -ne "Closed"))
{
$IncUrgency = $Inc.Urgency.DisplayName
switch ($IncUrgency)
{
	"Low" {$SRUrgency = Get-SCSMEnumeration -Computer $Computer -Name ServiceRequestUrgencyEnum.Low}
	"Medium" {$SRUrgency = Get-SCSMEnumeration -Computer $Computer -Name ServiceRequestUrgencyEnum.Medium}
	"High" {$SRUrgency = Get-SCSMEnumeration -Computer $Computer -Name ServiceRequestUrgencyEnum.High}
	default {$SRUrgency = Get-SCSMEnumeration -Computer $Computer -Name ServiceRequestUrgencyEnum.Medium}
}
$IncSource = $Inc.Source.DisplayName
switch ($IncSource)
{
	"E-Mail" {$SRSource = Get-SCSMEnumeration -Computer $Computer -Name ServiceRequestSourceEnum.Email}
	"Portal" {$SRSource = Get-SCSMEnumeration -Computer $Computer -Name ServiceRequestSourceEnum.Portal}
	default {$SRSource = Get-SCSMEnumeration -Computer $Computer -Name ServiceRequestSourceEnum.Other}
}
$SRIncText = "[Formerly Incident " + $Inc.ID + "]"
$SRDescription = $SRIncText + " " + $Inc.Description
New-SCSMObject -Computer $Computer -Class $SRClass -PropertyHashtable (@{ID = "SR{0}"; Title = $Inc.Title; Description = $SRDescription; Urgency = 
$SRUrgency; Source = $SRSource; Priority = "Medium"; Status = "New"})
$FilterStr = "Description -eq '$SRDescription'"
$SR = Get-SCSMObject -Computer $Computer -Class $SRClass -Filter $FilterStr
$RWIClass = Get-SCSMRelationshipClass -Computer $Computer -Name System.WorkItemRelatesToWorkItem$
New-SCSMRelationshipObject -Computer $Computer -Relationship $RWIClass -Source $Inc -Target $SR -Bulk
$IncResCat = Get-SCSMEnumeration -Computer $Computer -Name IncidentResolutionCategoryEnum.Cancelled
$IncResDes = "Incident replaced by Service Request " + $SR.ID
$IncStatus = Get-SCSMEnumeration -Computer $Computer -Name IncidentStatusEnum.Resolved
Set-SCSMObject -Computer $Computer -SMObject $Inc -PropertyHashtable (@{ResolutionCategory = $IncResCat; ResolutionDescription = $IncResDes; Status = 
$IncStatus})
}
Write-Host "* * * * * *"
Write-Host "IMPORTANT - Affected user must be manually assigned within the new SR"
Write-Host "* * * * * *"
Remove-Module SMlets
Write-Host "IR to SR process completed"

Konsola giderek bir Incident seçip Task işlemini test edebiliriz.

Task sonucu açılan pencerede görülüyor. Yapılacak tek şey Service Request çağrısını açarak Affected User bölümünü elle doldurmaktır.

Incident ise otomatik olarak Resolved durumuna geldi. Resolution kısmına bakarsak kodda belirtilen bilginin yazıldığını görüyoruz.

Task‘ın çalışmaması durumunda kontrol edilecek bir kaç ayarı burada belirtmemiz fayda sağlayabilir.

Oluşturduğumuz paylaşımın uzak kullanıcılar tarafından ulaşılır olduğuna emin olmalıyız. Herhangi bir destek uzmanının bilgisayarından dosyayı paylaşımdan çalıştırmayı deneyebiliriz.

Bazı durumlarda güvenlik politikaları sebebiyle paylaşımdan kod çalıştırmak kısıtlanmış olabilir. Bunu aşmak için:

Control Panel/Internet Options/Security/Local Intranet seçip SCSM sunucusunu eklememiz gerekiyor.

Kod Kaynak: http://gallery.technet.microsoft.com/Create-Incident-from-f19aaea0

Related Posts

Cireson Self Service Portal Database Migration

If you are planning to move the Service Manager database, you should also need to move the Cireson Service Desk Portal to the same instance. Stop the…

Service Manager Reporting Server Database Migration

In the previous post, I explained the steps of moving the Service Manager Data Warehouse databases to another SQL instance. In this post, I will share the…

Service Manager Data Warehouse Database Migration

Microsoft has documented in details how to move Service Manager Data Warehouse databases to another SQL instance. Do not attempt to move the Reporting Services database in…

In-place OS Upgrade of Service Manager Data Warehouse

In this post, I will show the steps for in-place upgrade of Service Manager Data Warehouse management server (2019) OS from Microsoft Server 2016 to 2019. The…

Installing Zebra printer driver with SCCM

In order to install Zebra printer driver to the computers with SCCM, you will first need to extract the driver content from the exe file. Deselect all…

In-place OS Upgrade of Service Manager Data Warehouse Server

In this post, I will show the steps for in-place upgrade of Service Manager Data Warehouse management server (1801) OS from Microsoft Server 2012 R2 to 2016….