Creating dynamic computer groups using regular expressions in OpsMgr | Quisitive
Creating dynamic computer groups using regular expressions in OpsMgr
November 11, 2009
Cameron Fuller
Our expert show you how to create dynamic computer groups

I had a requirement to take a series of servers and put them into different groups based upon their names. We have a series of production and test web servers which are named:

  • ws01 through ws05 (for the production servers)
  • ws01t through ws05t (for the test servers)

We could have explicitly defined what servers are members of each computer group, but to simplify management going forward we wanted to have it dynamic so that if additional web servers are added (such as ws06 or ws06t) they would automatically become part of the computer group. To do this we needed to create use regular expressions.

So, we start out with creation of a group called Production- Web Servers as shown below.

Groups01

When we are in the wizard we can choose to define dynamic members. For this we use the query builder to match two different conditions:

1) Where the DNS name for the Windows Computer matches the regular expression of ws[0123456789][0123456789]. This expression means that any servers starting with the name ws that have numbers in the next two positions and have a period at the end are a match. The period is used to make sure that servers which just start with the expression don’t match (such as our ws01t systems).

2) Where the Display Name for the Health Service Watcher (Agent) matches the same regular expression. We add the Health Service Watcher (Agent) so that we can receive heartbeat alerts based upon subscriptions which we define for this group.

Groups03

The screen below shows how the information added in the query builder is populated into the query formula.

Groups02

The members of this group are shown below. This group now matches the ws01-ws05 systems for both the windows computer and health service entities. Equivalent test system (ws01t-ws05t) are not part of this production web group.

groups04

The next step is to create a second group called Test- Web Servers which matches these conditions:

1) Where the DNS name for the Windows Computer matches the regular expression of ws[0123456789][0123456789]t. The addition of the t verifies that we will match only the test servers.

2) Where the Display Name for the Health Service Watcher (Agent) matches the same regular expression. We add the Health Service Watcher (Agent) so that we can receive heartbeat alerts based upon subscriptions which we define for this group.

So, now we have two dynamic groups based upon server names! So going forward as we add either production or test web servers they will automatically populate into the appropriate groups in OpsMgr.

Summary: Using dynamic groups with OpsMgr is pretty straightforward and pretty powerful. When creating these groups you can use a regular expression which will match your servers for various criteria including server name. Be sure to use the criteria “Matches Regular Expression” and define the value to contain options which are acceptable within brackets (as an example [0123456789] – for any number or [abcdefghijklmnopqrstuvwxyz] to match any letter).