Deleting Objects in Bulk in the CMDB using PowerShell

Deleting Objects in Bulk in the CMDB using PowerShell

  • Comments 16
  • Likes

Ever wish you could just start over? :)

I’ve been using this PowerShell script that Jim Truher (PM on the Service Manager product team) wrote so much lately that I think it is essential to any Service Manager veteran’s toolkit and so I want to increase its visibility here on the team blog.

This PowerShell script allows you to delete any object in the ServiceManager DB in bulk.  Why would you want to do that?  Let me tell you – this works wonders to help reset demo environments.  It would also work great in testing situations.  And sometimes you just want to be able to start over – maybe that CSV import didn’t go just the way you wanted it to.  :)

Be super careful with this script near any data that you care about though.  Jim added –WhatIf support and I recommend using it!

Here is a link to Jim’s blog (which I highly recommend if you are into using PowerShell with Service Manager):

http://jtruher.spaces.live.com/blog/cns!7143DA6E51A2628D!843.entry

image

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • What happens if you delete an object that is related to other objects? How does the delete cascade through the relationships?

  • @Adam -

    It depends on the relationship type.  If you delete an object all of the objects which are "members" of that object or are "hosted" by that object will also be deleted.  If the objects are related to the object being deleted by a containment or a reference relationship they will not be deleted.

    Example of hosting relationship -

    Windows Computer hosts Operating System

    Example of membership relationship -

    Change request has member activity

    Example of containment relationship -

    Group contains computer

    Example of reference relationship -

    Incident is assigned to a user