Skip to content

Instantly share code, notes, and snippets.

@KirkMunro
Last active August 29, 2015 13:57
Show Gist options
  • Save KirkMunro/9791294 to your computer and use it in GitHub Desktop.
Save KirkMunro/9791294 to your computer and use it in GitHub Desktop.
A brief introduction to some of the capabilities provided by the ScsmPx module.
# Get all commands included in the ScsmPx module
Get-ScsmPxCommand
# Get all commands included in the SCSM native modules
Get-SCSMCommand
# Get all raw System.WorkItem.Incident instances
Get-ScsmPxIncident
# Get all incidents as displayed in the "All Incidents" view in the System
# Center Service Manager Management Console
Get-ScsmPxIncident -View All
# Get all commands that can be used to manage incidents
Get-Command -Noun ScsmPxIncident
# Look up the Resolved incident status enumeration
$resolved = Get-ScsmPxListItem -ListName IncidentStatusEnum -Name Resolved
# Look up the Closed incident status enumeration
$closed = Get-ScsmPxListItem -ListName IncidentStatusEnum -Name Closed
# Identify our search filters (resolved incidents at least 7 days old)
$filters = @(
"(Status -eq '$($resolved.Id)')"
"(LastModified -lt '$([System.DateTime]::UtcNow.AddDays(-7))')"
)
# Now get any matching incidents and change their status to closed
Get-ScsmPxIncident -Filter ($filters -join ' -and ') |
Set-ScsmPxIncident -Property @{
Status = $closed
ClosedDate = [System.DateTime]::UtcNow
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment