Automating OpsMgr Part 10: Deleting Groups


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.


This runbook takes 2 parameters:


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

Runbook Result:


Verbose Messages (deleting dependency monitors):



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

This site uses Akismet to reduce spam. Learn how your comment data is processed.