Need PowerShell help - Adding some additional data to one of the field in Incident form (SCSM)

jansi rani krishnan 601 Reputation points
2021-08-17T15:43:27.977+00:00

Hi Team,

I need some PowerShell help to add/append some additional information as below to the existing information in the "Description" field in the Manual Activity form (SCSM). Actually no unused fields like "Alternate Contact Method" in incident form to make use for the same purpose.

SNOW sys_id: 5add24dd1b027c10d6557805464bcb11
SNOW Correlation Id: MA6601
SNOW Incident Task: TASK0060126

Also how to retrieve the above each information later from the description field.

Appreciate your help!!!

Regards,
Jansi

Service Manager
Service Manager
A family of System Center products for managing incidents and problems.
210 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Baumgarten 97,566 Reputation points MVP
    2021-08-17T16:24:12.757+00:00

    Hi @jansi rani krishnan ,

    it's almost the same like this one: https://learn.microsoft.com/en-us/answers/questions/498265/need-help-on-powershell-coding-regarding-scsm.html

    Here we go:

    # Set Manual Activity Description field  
    Import-Module SMlets  
    $smdefaultserver = "SCSM1"  
    # Define properties  
    $maID = "MA2114"  
    $SysID = "c21f57971b6d7c101d777b75464bcb26"  
    $SNOWticketID = "TASK0055836"  
    $status = "inserted"  
    ######  
    $maClass = Get-SCSMClass -Name System.WorkItem.Activity.ManualActivity$  
    # Get SCSM objects  
    $maObj = Get-SCSMObject -Class $maClass -Filter "ID -eq $maID"  
    # Update IR Alternate Contact Method  
    if (($status -eq "inserted") -and ($maObj)) {  
        $UpdateDescription = "Sysid: $SysID | SNOW ticket number: $SNOWticketID | Correlation_id: $maID"  
        Set-SCSMObject -SMObject $maObj -Property "Description" -Value $UpdateDescription  
    }  
      
    #######  
      
    # Get the data out of the Manual Activity Description field  
    $maID = "MA2114"  
    $maClass = Get-SCSMClass -Name System.WorkItem.Activity.ManualActivity$  
    $maObj = Get-SCSMObject -Class $maClass -Filter "ID -eq $maID"  
    $maDescription = $maObj.Description  
    $sysID = ($maDescription.Split("|")[0].Split(":").Trim())[1]  
    $SysID  
    # Get SNOW Ticket ID  
    $SNOWticketID = ($maDescription.Split("|")[1].Split(":").Trim())[1]  
    $SNOWticketID  
    # Get SCSM MA ID  
    $maID = ($maDescription.Split("|")[2].Split(":").Trim())[1]  
    $maID  
    

    ----------

    (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.
    0 comments No comments