Automating OpsMgr Part 10: Deleting Groups

Written by Tao Yang

OpsMgrExntededIntroduction

This is the 10th instalment of the Automating OpsMgr series. Previously on this series:

As I have previously demonstrated how to create and update OpsMgr groups using the OpsMgrExtended module, it’s now the time cover how to delete groups in OpsMgr.

Deleting groups that are defined in unsealed management packs can be easily accomplished using the Remove-OMGroup function from the OpsMgrExtended module. This function deletes the group class definition and discoveries from the unsealed MP. However, since it’s very common for OpsMgr administrators to also create dependency monitors for groups (for group members health rollup), you cannot simply use Remove-OMGroup function to delete groups when there are also monitors targeting this group. Therefore, I have written  a sample runbook to delete the group as well as monitors targeting the group (if there are any).

Runbook Delete-OpsMgrGroup

In order to use this runbook, you will need to update Line 9, with the name of your SMA connection object.

SNAGHTML1591389

This runbook takes 2 parameters:

image

GroupName: the name of the group you are deleting. Please note you can only delete groups defined in unsealed MPs.

IncreaseMPVersion: Boolean variable, specify if the unsealed MP version should be increased by 0.0.0.1

Runbook Result:

image

Verbose Messages (deleting dependency monitors):

SNAGHTML14fa1a1

 

Conclusion

This post is rather short comparing to some of the previous ones in this series. I have few ideas for the next post, but haven’t decided which one am I going to write first. Anyways, until next time, happy automating!

Leave a Reply