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