Automating OpsMgr Part 4: Create New Empty Groups

OpsMgrExntededIntroduction

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

When developing management packs, it is very common to define various groups that contain objects discovered by the management pack. The groups can be used for overrides, maintenance modes, reports, scoping user access, etc.

Generally speaking, there are 2 types of groups in OpsMgr: instance groups and computer groups. As the names suggested, instance groups can contain any types of instances in OpsMgr, and computer groups can only contain computer objects.

In the OpsMgr console, the easiest way to identify the group type is by the icon. i.e.

image

As you can see, the computer group has an additional computer in the icon.

There are 2 steps when creating a group:

1. Class definition – A singleton, unhosted group class representing the group itself. i.e.

image

2. A discovery workflow which uses A Data Source module type called “Microsoft.SystemCenter.GroupPopulator” to populate the group membership. i.e.

image

The class definition and the discovery can be defined in the same management pack, or different packs (i.e. Class definition in a sealed MP, and discovery MP can reference the sealed class definition MP). As you can see, the class definition for groups are really simple, but the discovery can sometimes get very complicated – all depending on your requirements.

When I was developing the OpsMgrExtended module, I have created 2 functions for group creations:

  • New-OMInstanceGroup
  • New-OMComputerGroup

As the names suggest, these 2 functions create new instance groups and computer groups respectively. But because the group populations can sometimes be tricky and complicated, after careful consideration, I have decided to code these 2 functions to only create empty groups and users will have to either manually populate the groups via the operations console, or developing their own runbooks to update the group discovery workflow.

So what does an empty group mean?

I simply coded the group populator data source to always return nothing by using a simple expression where True equals False (which would never happen):

image

Since populating groups can get complicated, and I think it will be very useful for people to use the OpsMgrExtended module to create and manage groups, I will dedicate this post and the next few posts in this blog series on creating and managing groups. So, please consider this as the first episode of the “sub series”. In this post, I will demonstrate a simple runbook that you can use to create instance groups and computer groups.

Runbook: New-Group

Executing Runbook

Creating Instance Group:

image

Creating Computer Group:

image

Results:

In Operations Console:

image

Management Pack – Class Definition:

image

Management Pack – Instance Group Discovery:

image

Management Pack – Computer Group Discovery:

image

Management Pack – Language Pack:

image

Additional Readings

Over the years I’ve been working with OpsMgr, I’ve booked mark the following great blog articles on creating groups in OpsMgr. You might find some of them useful:

Also, few previous posts from this blog:

Conclusion

In this post, I have demonstrated how to create computer groups and instance groups without any members. In the next post, I will demonstrate a runbook to add an explicit member to a computer group.

2 comments

  1. Thanks for the toolbox.
    One question : i’ve create several groups with scripting, and now i’ve got error message below :

    VERBOSE: Increasing MP version to 1.0.0.309
    VERBOSE: Saving Management Pack FRPRODTOUTMUTMPGENWINDOWSSERVICES
    New-OMComputerGroup : Unable to create Computer Group FRPRODTOUTMUTMPGENWINDOWSSERVICES.Toulon in management pack
    FRPRODTOUTMUTMPGENWINDOWSSERVICES.
    At line:1 char:1
    + New-OMComputerGroup -SDK “MS04” -MPName “FRPRODTOUTMUTMPGENWINDOWSSER …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,New-OMComputerGroup

    what is this WriteErrorException ?

    Thanks
    Emmanuel

Leave a Reply

%d bloggers like this: