Skip to content

Instantly share code, notes, and snippets.

@justincjahn
Created June 20, 2014 18:33
Show Gist options
  • Save justincjahn/784decc3ec337ceafe94 to your computer and use it in GitHub Desktop.
Save justincjahn/784decc3ec337ceafe94 to your computer and use it in GitHub Desktop.
Export SCSM Incidents including analyst and affected user names.
Import-Module SMLets
$IRClass = Get-SCSMClass -Name System.WorkItem.Incident
$ASClass = Get-SCSMRelationshipClass -Name System.WorkItemAssignedToUser$
$AFClass = Get-SCSMRelationshipClass -Name System.WorkItemAffectedUser$
$IR = Get-SCSMObject -Class $IRClass | Select -Property `
@{Label="Queue";Expression={$_.TierQueue.displayname}}, `
Id, `
Title, `
@{Label="AffectedUser";Expression={(Get-SCSMRelatedObject -SMObject $_ -Relationship $AFClass).DisplayName}}, `
@{Label="Source";Expression={$_.Source.displayname}}, `
Description, `
Priority, `
@{Label="Impact";Expression={$_.Impact.displayname}}, `
@{Label="Urgency";Expression={$_.Urgency.displayname}}, `
@{Label="Classification";Expression={$_.Classification.displayname}}, `
@{Label="AssignedToUser";Expression={(Get-SCSMRelatedObject -SMObject $_ -Relationship $ASClass).DisplayName}}, `
CreatedDate, `
FirstAssignedDate, `
FirstResponseDate, `
@{Label="Status";Expression={$_.Status.displayname}}, `
@{Label="ResolutionCategory";Expression={$_.ResolutionCategory.displayname}}, `
ResolvedDate, `
ResolutionDescription
$IR | Export-CSV -NoTypeInformation -Path 'C:\Users\justinjahn\Documents\incidents.csv' -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment