Dynamic Group Population in OpsMgr with regular expressions

Over time there have been several excellent posts to guide people in how to dynamically populate groups using regular expressions.The ones I found however did not answer the question I had regarding the grouping I wanted to make.

Consider the following situation:

Your servers are named as follows:

  • NY-DC01
  • NY-TS02
  • NY-BIZ01
  • NY-DB01
  • NY-WEB01
  • NY-WEB02
  • NY-WEB03
  • NY-WEB04
  • NY-WEB05
  • LA-DC01
  • LA-DB01
  • LA-WEB01
  • LA-WEB02

In the above situation I have multiple webservers (All starting with ‘NY-WEB’ or ‘LA-WEB’) and a bunch of other servers (Database, Biztalk, Terminal Server etc.). In my case I wanted to make a selection of all New York servers not being web-servers. Furthermore, since OpsMgr is case sensitive where it comes to groupings, I wanted to make the selection case insensitive.

In this case I could use a regular expression with an inclusion to include all servers starting with ‘NY-‘ as well as an exclusion to exclude servers containing ‘web’ and get what I need. To achieve what I want, I need the following regular expression:

  • ^(?i:ny-)(?!(?i:web)).*$

‘^(?i:ny-)’ will make a case insensitive selection of all servers starting with ‘ny-‘. ‘(?i:web)’ is another case insensitive selection of all servers containing the text ‘web’, and this selection in turn is excluded by ‘(?!…)’, by which it is enclosed.

To create the group, perform the following steps:

  1. In the operations console, create a new Group under ‘Authoring’ > ‘Groups’
  2. Give it a name of your choice and select a managementpack to save it in (not the default managementpack)
  3. Select ‘Next’ twice and click ‘Create/Edit Rules…’
  4. Verify ‘Windows Computer’ is selected and click ‘Add’
  5. Now select ‘principal name’ > ‘Matches regular expression’
  6. Now entering this: ^(?i:ny-)(?!(?i:web)).*$ should do the trick
  7. Click ‘OK’
  8. Click ‘Next’ twice and ‘Create’
  9. Now test your group by selecting the group and clicking ‘view group members…’

Some very good posts on regular expressions in Operations Manager can be found here: