Get-SCSMIncident with extensions

Jul 17, 2014 at 3:45 PM
Hi friends,

I´m new user in this forum :)

I need to get some informations in Resquest Incident (RI) "custom form". I´m using powershell SMlests to get it:

Import-Module SMlets -CMDlet get-scsmclass,get-scsmobject
Get-SCSMIncident -ID 'RI11612' | ft

When I run the command i get only informations about default form "without" extensions fields.

My question is, how can i get all informations in RI with extensions fields?
Feb 2, 2015 at 11:12 AM

It seems to me that you are experiencing the same problem as I had.

Your information is probably stored in either a extension of the request incident class (for custom attributes) or stored in a relationship class.
Look through all your classes for Request records and see if you need to choose another: ClassExtension_<id>
when prompting asking for information.

So try to investigate the correct Incident class and then define that class to retrieve all information in the custom attributes you created.

# Get my extended class of Incident with my custom attributes
$IncidentClass = Get-SCSMclass -SCSMSession $scsm -Name ClassExtension_da3e_asd123_213_qed23

# I use filter as a variable and here i made use of Get-Date function to get 2 separate dates as a intervall of the records i want, and
# I also wanted to exclude cases created by Operations Manager from my output.
$filter_ExcludeAlarm = "CreatedDate -ge '$startDate' AND CreatedDate -le '$endDate' AND Source -ne '$opManager'"

# Here i use the GET function to retrieve objects of the Extended Incident class with a FILTER for records between 2 specified dates.
$iRecords = Get-SCSMobject -SCSMSession $scsm -Class $IncidentClass -Filter $filter_IncludeAlarm

# Generate report based on the selected records from our Criteria.
$outReport = @()

# Run foreach command to loop through the Incident objects and retrieve information
If ($iRecords.count -gt 0){
    foreach ($rRecord in $iRecords){
        # add what you want to do here
        $objReport = New-Object System.Object

        # Add attribute for to Object
        $objReport | Add-Member -type NoteProperty -Name 'Record ID' -Value $rRecord.Id
        $objReport | Add-Member -type NoteProperty -Name 'Your unique attribute' -Value $rRecord.<yourCustomAttribute>
        # Add object to array
        $outReport += $objReport
# Dump out the imput from the array
# Or even better dump it into a TXT file
$outReport | Export-Csv "C:\<your>\<path>\<and filename>.txt -encoding "unicode"
There is probably better and more efficient ways of doing this but this is how i solved unique reports based on custom attributes and relationships.
Within the for each i could get correct relationship attributes by calling Get-SCSMRelatedObject on the $rRecord object and whoops i had access to the correct data for the record.