Using SMLets Beta 3 Post #9–Deleting Objects

Published Feb 15 2019 07:37 AM 173 Views
First published on TECHNET on Jul 13, 2011
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.

%3CLINGO-SUB%20id%3D%22lingo-sub-343661%22%20slang%3D%22en-US%22%3EUsing%20SMLets%20Beta%203%20Post%20%239%E2%80%93Deleting%20Objects%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-343661%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20TECHNET%20on%20Jul%2013%2C%202011%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20We%E2%80%99ve%20discussed%20this%20lots%20of%20times%20before%20in%20different%20blog%20posts%20in%20different%20forms%2C%20but%20I%E2%80%99ll%20just%20put%20it%20out%20here%20one%20more%20time%20in%20a%20condensed%20form.%26nbsp%3B%20You%20can%20use%20%3CA%20href%3D%22http%3A%2F%2Fsmlets.codeplex.com%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20SMLets%20%3C%2FA%3E%20to%20delete%20objects%20from%20the%20CMDB.%26nbsp%3B%20Here%20are%20some%20examples%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Get-SCSMObject%20%E2%80%93Class%20(Get-SCSMClass%20%E2%80%93Name%20System.WorkItem.Incident%24)%20%7C%20Remove%20%E2%80%93SCSMObject%20%E2%80%93Force%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20That%20will%20delete%20all%20incidents%20in%20the%20system.%26nbsp%3B%20You%20can%20use%20other%20class%20IDs%20like%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CUL%3E%0A%20%20%20%3CLI%3ESystem.WorkItem.ChangeRequest%24%3C%2FLI%3E%0A%20%20%20%3CLI%3ESystem.WorkItem.Problem%24%3C%2FLI%3E%0A%20%20%3C%2FUL%3E%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20If%20you%20need%20to%20look%20up%20other%20class%20IDs%20you%20can%20run%20a%20cmdlet%20like%20this%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Get-SCSMClass%20%7C%20FT%20Name%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20You%20can%20also%20filter%20the%20results%20of%20the%20Get-SCSMObject%20cmdlet%20if%20you%20only%20want%20to%20delete%20certain%20objects.%26nbsp%3B%20For%20example%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Get-SCSMObject%20%E2%80%93Class%20(Get-SCSMClass%20%E2%80%93Name%20System.WorkItem.Incident%24)%20%E2%80%93Filter%20%E2%80%9CTitle%20%E2%80%93eq%20%E2%80%98Some%20title%E2%80%99%E2%80%9D%7C%20Remove%E2%80%93SCSMObject%20%E2%80%93Force%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Get-SCSMObject%20%E2%80%93Class%20(Get-SCSMClass%20%E2%80%93Name%20System.WorkItem.Incident%24)%20%E2%80%93Filter%20%E2%80%9CTitle%20%E2%80%93like%20%E2%80%98%25something%25%E2%80%99%E2%80%9D%7C%20Remove%E2%80%93SCSMObject%20%E2%80%93Force%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CP%3EFeel%20free%20to%20share%20your%20techniques%20of%20using%20these%20cmdlets%20with%20others%20in%20the%20comments.%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-343661%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TECHNET%20on%20Jul%2013%2C%202011%20We%E2%80%99ve%20discussed%20this%20lots%20of%20times%20before%20in%20different%20blog%20posts%20in%20different%20forms%2C%20but%20I%E2%80%99ll%20just%20put%20it%20out%20here%20one%20more%20time%20in%20a%20condensed%20form.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-343661%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESystem%20Center%20Service%20Manager%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Mar 11 2019 08:49 AM
Updated by: