Using SMLets Beta 3 Post #9–Deleting Objects

We’ve discussed this lots of times before in different blog posts in different forms, but I’ll just put it out here one more time in a condensed form.  You can use SMLets to delete objects from the CMDB.  Here are some examples:

Get-SCSMObject –Class (Get-SCSMClass –Name System.WorkItem.Incident$) | Remove –SCSMObject –Force

That will delete all incidents in the system.  You can use other class IDs like:

  • System.WorkItem.ChangeRequest$
  • System.WorkItem.Problem$

If you need to look up other class IDs you can run a cmdlet like this:

Get-SCSMClass | FT Name

You can also filter the results of the Get-SCSMObject cmdlet if you only want to delete certain objects.  For example:

Get-SCSMObject –Class (Get-SCSMClass –Name System.WorkItem.Incident$) –Filter “Title –eq ‘Some title’”| Remove–SCSMObject –Force

Get-SCSMObject –Class (Get-SCSMClass –Name System.WorkItem.Incident$) –Filter “Title –like ‘%something%’”| Remove–SCSMObject –Force

Feel free to share your techniques of using these cmdlets with others in the comments.