Create automatic groups using wildcard computer names such as Desktops are named ?D*

Is it possible to create automatic computer groups using the following computer names convention that are similar to WSUS setup expressions or some other method where Desktops are named ??D*, Laptops ??L* & Servers ??S*.

This is the format of the computer name
The first two letters are for the site, so in this example its location site CA
The 3rd letter defines the machine type (D=Desktop, L=Laptop, S=Server).
Then the numbers are usually 3 digits, but can be bigger depending on the site
Example

CAD001 = desktop
CAL001 = Laptop
CAS001 = server

1 Like

Yep, this is possible using regular expressions in relevance.

So for example:

exists computer name whose (it as lowercase starts with (regex “[a-z][a-z]d”))

This is a very simple regex that simply matches the first two characters with a lowercase a-z, followed by a lowercase d, so would match your naming convention for desktops.

For laptops and servers, simply substitude l or s for d, respectively. Any of these expressions will not care about following numbers, because with the Starts With operator and the three specific character combinations we’re only inspecting the first three characters of the computer name.

1 Like

Thanks MWolff as that was exactly what i was looking for.

1 Like

how would i combine these two into one relevance statement so that if either are true then it will return true?

exists computer name whose (it as lowercase starts with (regex “[a-z][a-z]d”))
exists computer name whose (it as lowercase starts with (regex “[a-z][a-z]l”))

Extend the regex

exists computer name whose (it as lowercase starts with (regex “[a-z][a-z][dl]”))

any letter, any letter, d or l

2 Likes

I agree with @trn that in this case extending the regex is cleaner.

In general though, the way to combine to clauses such that the result is true if either clause is true is with OR.

exists computer name whose (it as lowercase starts with (regex “[a-z][a-z]d”)) OR
exists computer name whose (it as lowercase starts with (regex “[a-z][a-z]l”))

Thanks to everyone as always with quick responses.

How would you look for server names that contain NB in thr middle(not case sensitive).
Ie. Server name: AbcdNBXyz01

Computer name as lowercase contains "nb"
1 Like

Thank you, but I don’t want it to start with nb

So…just characters 5 & 6 should be “nb”?

Hey Jason, even the 2nd and 3rd.
I want to avoid servers starting with NB

following text of first 1 of computer name as lowercase contains "nb"
1 Like

Thanks I’ll test it :slight_smile: