question

jansiranikrishnan-1796 avatar image
0 Votes"
jansiranikrishnan-1796 asked AndreasBaumgarten commented

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

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

windows-server-powershellmsc-service-manager
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @jansiranikrishnan-1796 ,

did the answer work for you? Are there any additional questions to this topic?

If you found the answer helpful, it would be great if you please mark it "Accept as answer". This will help others to find answers in Q&A

----------
Regards
Andreas Baumgarten

0 Votes 0 ·

1 Answer

AndreasBaumgarten avatar image
1 Vote"
AndreasBaumgarten answered AndreasBaumgarten edited

Hi @jansiranikrishnan-1796 ,

it's almost the same like this one: https://docs.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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.