none
Removing Incident Records from Service Manager Database

    Question

  • We had an issue occur where a user set an "Out of Office" rule that looped and created over 1500 Incidents in SCSM.  We Closed all the calls, but want to remove those individual Incidents from the database as they are throwing off our monthly stats. 

    We've read Travis's blog on "Deleting Objects in Bulk", but in reviewing this with our DBA, he's not sure what Table to target in the ServiceManager database to ensure only these records are removed.

    Can you let us know what the best Table field would be to identify if the "Title" is consistently the same or target by the Affected User, which Table Field should be used.

    Thank you


    Denise
    Wednesday, September 01, 2010 2:35 PM

Answers

  • Hi DeniseL

    You can use this PowerShell command line:

    get-scsmtypeprojection System.WorkItem.Incident.ProjectionType|Get-SCSMObjectProjection|?{$_.AffectedUser -like '*Name of affected user*' -and $_.CreatedDate -lt (Get-Date 09/22/2010) -and $_.CreatedDate -gt (Get-Date 07/22/2010)}|%{$_.object}|remove-scsmobject -force -whatif

    You will need to have the smlets PowerShell module installed: http://smlets.codeplex.com/

    Modify the filter as needed. Execute the command with the "-whatif" switch (as in the example above), this will show you which incidents will be deleted when you run the same command line without the "-whatif" switch.

    Edit: Please be careful using this command line, it's powerful stuff :)


    Patrik Sundqvist Solutions Architect http://blogs.litware.se
    Thursday, September 09, 2010 8:36 PM

All replies

  • Hi, is this the power shell script that you have been looking at ? http://jtruher.spaces.live.com/blog/cns!7143DA6E51A2628D!843.entry?sa=711368810
    Anders Bengtsson | Microsoft MVP - Operations Manager | http://www.contoso.se
    Wednesday, September 01, 2010 2:43 PM
  • Yes


    Denise
    Wednesday, September 01, 2010 2:58 PM
  • Could we possibly get an answer on this soon, as our management is looking to get stats from SCSM and right now these 1500+ records are messing up our numbers.  We would really like to know the best way in which to target these particular records, by knowing which table to identify.

    Thanks


    Denise
    Thursday, September 09, 2010 12:48 PM
  • Hi DeniseL

    You can use this PowerShell command line:

    get-scsmtypeprojection System.WorkItem.Incident.ProjectionType|Get-SCSMObjectProjection|?{$_.AffectedUser -like '*Name of affected user*' -and $_.CreatedDate -lt (Get-Date 09/22/2010) -and $_.CreatedDate -gt (Get-Date 07/22/2010)}|%{$_.object}|remove-scsmobject -force -whatif

    You will need to have the smlets PowerShell module installed: http://smlets.codeplex.com/

    Modify the filter as needed. Execute the command with the "-whatif" switch (as in the example above), this will show you which incidents will be deleted when you run the same command line without the "-whatif" switch.

    Edit: Please be careful using this command line, it's powerful stuff :)


    Patrik Sundqvist Solutions Architect http://blogs.litware.se
    Thursday, September 09, 2010 8:36 PM
  •  I want to delete scsm 2010 sp1 all incidents  kindly tell how to delete them please urgent help required
    Tuesday, May 31, 2011 9:34 PM
  • Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.Incident$) | remove-scsmobject -force -whatif
    remove -whatif to really delete incident from DB


    http://opsmgr.ru
    Wednesday, June 01, 2011 9:09 AM