Need powershell help to retrieve incident information

jansi rani krishnan 601 Reputation points
2021-04-28T16:44:19.673+00:00

Hi Team,

I have a requirement to retrieve a particular incident information

Example:

I can fetch the whole set of incident information using the below command.

$IC=get-SCSMclass -name system.workitem.incident$
$IO=get-SCSMobject -class $IC | select-object *

I have no idea on how to retrieve a particular data like Title, Description, urgency, impact individually and store in a separate variable

Can anyone please help me out on how to proceed?

It would really be a great help!!!

Thanking you in advance.

Regards,
-Jansi

Service Manager
Service Manager
A family of System Center products for managing incidents and problems.
205 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,273 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 91,766 Reputation points MVP
    2021-04-28T17:26:37.757+00:00

    Hi. @jansi rani krishnan ,

    maybe this will help:

    Import-module SMlets # Implort SMLets module  
    $smdefaultserver = "SCSM1" # Define SCSM Management Server  
    $IRid = "IR2031" # Define Incident Record  
    $IRclass=Get-SCSMclass -name System.Workitem.Incident$ # Get SCSM Incident class object  
    $IRobject=Get-SCSMobject -class $IRclass -filter "ID -eq $IRid" # Get IR object  
    $IRobject | fl # show all properties and values of the IR object  
      
    # Set dedicated variables with IR properties  
    $Title = $IRobject.Title  
    $Description = $IRobject.Description  
    $Status = $IRobject.Status  
    $Impact = $IRobject.Impact  
    $Urgency = $IRobject.Urgency  
    $Id = $IRobject.Id  
    $CreatedDate = $IRobject.CreatedDate  
    $LastModifiedDate = $IRobject.LastModified  
    $Classification = $IRobject.Classification.DisplayName  
    $SupportGroup = $IRobject.TierQueue.DisplayName  
    

    If you like you can take a look here for some more SCSM related PowerShell scripts. These scripts were published in the Microsoft TechNet Gallery before (which is retired now):
    https://github.com/abaumgarten42/SCSM_Useful_PSscripts

    ----------

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

    Regards
    Andreas Baumgarten


1 additional answer

Sort by: Most helpful
  1. Andreas Baumgarten 91,766 Reputation points MVP
    2021-04-29T15:31:00.06+00:00

    Hi @jansi rani krishnan ,

    the line $IRobject | fl should just output the full Incident Record with all fields and values. Works here ... but is not important for the rest of the script.

    To get the second line of Description you can give this a try:

    $Description = "This is line 1  
    This is line 2  
    This is line 3"  
    $secondLine = ($Description.Split([Environment]::NewLine))[1] # Number starts with 0 for first line  
    $secondLine  
    

    ----------

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

    Regards
    Andreas Baumgarten