Skip to content

Instantly share code, notes, and snippets.

@BenNeise
Last active January 2, 2016 02:19
Show Gist options
  • Save BenNeise/8236374 to your computer and use it in GitHub Desktop.
Save BenNeise/8236374 to your computer and use it in GitHub Desktop.
Lists open calls in SCSM 2012 using only native CMDlets (no SMLets)
# Import the SCSM Native CMDLets
Import-Module "C:\Program Files\Microsoft System Center 2012\Service Manager\Powershell\System.Center.Service.Manager.psd1"
# Name of your SCSM Server
$strSCSMServer = "YourSCSMServer"
New-SCSMManagementGroupConnection -ComputerName $strSCSMServer
$objRelationshipAssignedToUser = Get-SCSMRelationship -Name "System.WorkItemAssignedToUser"
$objRelationshipAffectedUser = Get-SCSMRelationship -Name "System.WorkItemAffectedUser"
# Get an object containing all open incidents
$objIncidentsOpen = (Get-SCClassInstance -Class (Get-SCClass -Name "System.WorkItem.Incident")) | Where-Object {
$_.Status.ToString() -ne "IncidentStatusEnum.Closed" -and $_.Status.ToString() -ne "IncidentStatusEnum.Resolved"
}
# Format the object with calculated properties to display the required information
$objIncidentsOpen | Select-Object `
Id,
Title,
@{Name="Source";Expression={$_.Source.DisplayName}},
CreatedDate,
Priority,
@{Name="Affected User";Expression={$_.GetRelatedObjectsWhereSource($objRelationshipAffectedUser)}},
@{Name="Status";Expression={$_.Status.DisplayName}},
@{Name="SupportGroup";Expression={$_.TierQueue.DisplayName}},
@{Name="Assigned To";Expression={$_.GetRelatedObjectsWhereSource($objRelationshipAssignedToUser)}}
# End of script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment