Quick tip – using regular expressions in a dynamic group


Here is a quick tip on using a regular expression when creating a group.

 

OpsMgr dynamic inclusion rules are case sensitive.

If I have a group that I want to contain all computers that START with “OM”…. I can use the following expression:

 

image

 

The “^” tells regex to start a new line… without this – it will search the entire computername for “OM” instead of only servers with a name that starts with “OM”.  This shows the following group membership:

 

image

 

However – this is not all my “OM” servers.  This is because when some were built, they used a lower case name.  If I change the dynamic inclusion expression to “^om” I will only see the lower case servers (the NetBIOS Computer name is lower case… not the display name as shown):

 

image

 

Ok – how do I get them ALL in the same group?

 

There are a couple ways.

One way is to “OR” the two regex queries:

 

image

 

Bingo!

 

image

 

Another way – courtesy of Tim Helton – is to use the regex modifier (?i:) to make it case insensitive:

 

image

 

Which yields:

 

image

 

 

This should make dynamic groups a bit easier.  We can expand this to add the HealthService Watcher objects, which is typical for groups that we will scope notifications to:

 

image

 

Which yields all my Windows Computers, and their Health Service Watcher components.

image

Comments (5)

  1. Anonymous says:

    This is very helpful Kevin.

    I was also stumped in using ? as a wildcard until I found the following which said to use a . instead of ? then it worked fine when searching for all computers starting with abc as an example, (?i:^abc.)  

    http://webcache.googleusercontent.com/search?q=cache:XWqH8ncjpkQJ:www.opsmanjam.com/OpsManJam%2520Library/Featured%2520Articles/Regular%2520expression%2520support%2520in%2520SCOM%25202007.docx+scom+using+regular+expressions+with+wildcards&cd=2&hl=en&ct=clnk&gl=au

    Cheers,

    John Bradshaw

  2. nomad says:

    I used this today and it helped me out.

  3. paul says:

    Awesome!!!  I have been beating myself up trying to figure out what should be a useful simple functionality and here it is very clearly explained, thank goodness!

  4. Manoj says:

    Really helpful tips.. Thanks Kevin

  5. Thanks Kevin. Really helpful. You rock as always!!

Skip to main content