Change teir queue/support group via PowerShell

alfie thomas 86 Reputation points
2021-05-18T17:17:16.983+00:00

Hi all,

Please bare with me as I am new to SCSM/PowerShell and Orchestrator.

I am looking to use Orchestrator to Monitor all incidents by a Classification using a Monitor object activity which would then just feed into a PowerShell Script via the Run .Net Script. What I am struggling with is how to pass the new created IR number into the PowerShell script for it to know what to IR it would be changing the support group on.

So, Request offering is sumitted via our Service Desk portal which creates an Incident with all the questions in the description field. What I need is the Runbook to fire the ID into a PowerShell script like mention. I am also struggling on how to find the Support group name and the PowerShell on how to then change it.

I have gotten to the below point and was wondering if anyone could help or advise?

97651-image.png

import-module 'C:\Program Files\Microsoft System Center\Service Manager\PowerShell\System.Center.Service.Manager.psd1'
import-module SMlets

Get-Command -module System.Center.Service.Manager

$IR=Get-SCSMClassInstance -Class (Get-SCSMClass -Name System.WorkItem.Incident) -Filter "Id -eq IR80007"
$IR_description=$IR.Description

write-host $IR_description
write-host " "

if ($IR_classification -match "Sage"){
if($IR_description -match "Are you seeing an error message when opening Sage: Yes")
{write-host "ACTION: Assigning to SUPPPORT TEAM NUMBER 1 "}
elseif($IR_description -match "Do you need a file unlocked: Yes")
{write-host "ACTION: assigning SUPPPORT TEAM NUMBER 2"
#Get-SCSMClassInstance -Class (Get-SCSMClass -Name System.WorkItem.Incident) -Filter "Id -eq IR80007"| %{ $.Classifcation = "Sage"; $ } | Update-SCSMClassInstance Get-SCSMObject -ClassName "System.WorkItem.Incident"
}

System Center Orchestrator
System Center Orchestrator
A family of System Center products that provide an automation platform for orchestrating and integrating both Microsoft and non-Microsoft IT tools.
217 questions
0 comments No comments
{count} vote

Accepted answer
  1. Andreas Baumgarten 98,621 Reputation points MVP
    2021-05-19T12:51:40.943+00:00

    Hi @alfie thomas ,

    here the script:

    Import-Module SMlets  
    $smDefaultComputer = "SCSM1"  
    $irID = "IR2046"  
      
    $supportGroup1 = "NC"  
    $supportGroup2 = "BS"  
    $irClassification = "Cirrus"  
      
    $classIncident = Get-SCSMClass -Name System.WorkItem.Incident$  
      
    $irObj = Get-SCSMObject -Class $classIncident -Filter "ID -eq $irID"  
    $irDescription = $irObj.Description  
    $irObjClassification = $irObj.Classification.DisplayName  
      
    if ($irObjClassification -eq $irClassification) {  
        if ($irDescription -match "Are you seeing an error message when opening Cirrus: Yes") {  
            Set-SCSMObject -SMObject $irObj -Property "TierQueue" -Value $supportGroup2  
            $result = "IR is classification $irClassification and SupportGroup $supportGroup2"  
        }  
        else {  
            if ($irDescription -match "Do you need a file unlocked: Yes") {  
                $newSupportGroup = "$enumSupportGroup1"  
                Set-SCSMObject -SMObject $irObj -Property TierQueue -Value $supportGroup1  
                $result = "IR is classification $irClassification and SupportGroup $supportGroup1"  
            }  
            else {  
                $result = "IR is classification $irClassification but no condition met"   
            }  
        }  
    }  
    else {  
        $result = "IR is not classification $irClassification"  
    }  
    $result  
    

    The script is based in the SMlets only.
    I added some $result variables for output. If you use this variable as Published Data in the Runbook Activity it's easier to figure out what the script found and did.

    And here some screenshots of the runbook activity:

    97799-image.png

    Published Data -> Result

    97904-image.png

    In the Runbook Tester it looks like this

    97865-image.png

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


3 additional answers

Sort by: Most helpful
  1. Andreas Baumgarten 98,621 Reputation points MVP
    2021-05-18T17:29:56.447+00:00

    Hi @alfie thomas ,

    you can pass the Incident ID from the Monitor Activity with the Published Data in your PowerShell script.

    Right click in the PowerShell script with right mouse button where the Incident Id should be placed and follow the steps in the screenshot:

    97652-image.png

    97636-image.png

    The result should look like this:

    97579-image.png

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    1 person found this answer helpful.

  2. Andreas Baumgarten 98,621 Reputation points MVP
    2021-05-19T10:03:24.977+00:00

    Hi @alfie thomas ,

    first of all: Avoid to use the SCSM built-in cmdlets in combination with SMLets in the same script (don't import both modules).
    I am using only the SMlets and it works fine for me.
    Make sure the 32bit version of the SMLets are installed on the SCORCH server. SCORCH is running PowerShell in 32-bit mode only. I am always using the 32-bit ISE for writing SCORCH PowerShell scripts.
    Any Write-Host will be ignored because in SCORCH you don't have a host to display the output.
    You need to modify this -Filter "Id -eq IR80007" to -Filter "Id -eq $IRid" (static IR to dynamic ID from Monitor-Object activity)

    If you like I can rewrite the script later (using SMLets only) and test the script in my SCSM/SCORCH test environment. Or you are giving it another try.
    Just let me know.

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


  3. alfie thomas 86 Reputation points
    2021-05-20T07:37:32.003+00:00

    Hi @Andreas Baumgarten ,

    This worked. Just wanted to drop a note saying thank you. This is hugely appreciated!!!

    Wish you all the best,
    Alfie.