Quantcast
Channel: SCSM PowerShell Cmdlets
Viewing all articles
Browse latest Browse all 306

New Post: Get-SCSMIncident with extensions

$
0
0
Hi,

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.

Example:
# 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
$outReport
# 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.

Viewing all articles
Browse latest Browse all 306

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>