Automating OpsMgr Part 4: Create New Empty Groups


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.


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.


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


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):


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

Workflow New-Group
[Parameter(Mandatory=$true)][ValidateSet('InstanceGroup', 'Computergroup')][String]$GroupType,

#Get OpsMgrSDK connection object
$OpsMgrSDKConn = Get-AutomationConnection -Name "OpsMgrSDK_TYANG"

#Validate MP
$ValidMP = InlineScript
$MP = Get-OMManagementPack -SDKConnection $USING:OpsMgrSDKConn -Name $USING:MPName
if ($MP.sealed)
$bValidMP = $false
Write-Error "Unable to create the group in a sealed management pack."
} else {
$bValidMP = $true

If ($ValidMP)
$newGroup = InlineScript
if ($USING:GroupType -ieq "InstanceGroup")
New-OMInstanceGroup -SDKConnection $USING:OpsMgrSDKConn -MPName $USING:MPName -InstanceGroupName $USING:GroupName -InstanceGroupDisplayName $USING:GroupDisplayName -IncreaseMPVersion $true
} elseif ($USING:GroupType -ieq "ComputerGroup") {
New-OMComputerGroup -SDKConnection $USING:OpsMgrSDKConn -MPName $USING:MPName -ComputerGroupName $USING:GroupName -ComputerGroupDisplayName $USING:GroupDisplayName -IncreaseMPVersion $true

If ($newGroup)
Write-Output "Group `"$GroupName`" created."
} else {
Write-Error "Unable to create group `"$GroupName`"."

Executing Runbook

Creating Instance Group:


Creating Computer Group:



In Operations Console:


Management Pack – Class Definition:


Management Pack – Instance Group Discovery:


Management Pack – Computer Group Discovery:


Management Pack – Language Pack:


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:


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.


  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
    New-OMComputerGroup : Unable to create Computer Group FRPRODTOUTMUTMPGENWINDOWSSERVICES.Toulon in management pack
    At line:1 char:1
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,New-OMComputerGroup

    what is this WriteErrorException ?


Leave a Reply

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

%d bloggers like this: