SCSM: Mass deleting incidents

Sometimes if you are testing the import of a bunch of incidents, it is necessary to delete them.

As usual you can do it with a one-line powershell:

This command deletes all incidents that are created from yesterday to now:

(Get-SCSMClass -Name "System.WorkItem.Incident" | Get-SCSMClassInstance)
 | where {$_.FirstAssignedDate -gt ((get-Date).addDays(-1))} | Remove-SCSMClassInstance

In SCSM you first have to retrieve the class you are interessted in. After that you search for all instances of this class. The last command Remove-SCSMInstance deletes all matching instances.

This entry was posted in English, Powershell, Service Manager, System Center 2012 and tagged . Bookmark the permalink.