Automatically update CMDB Groups from AD (Active Directory)

HeyMarkWarmack
Tera Expert

Automatically update CMDB Groups for Dynamic CI Groups from AD (Active Directory) group.

 

We are trying to automate the Windows Patching cycle Dynamic CI Groups / CMDB Groups from the Active Directory (AD) group picking the proper CI to be in the group.  This is used for the monthly Request for Change (RFC) or Change Request instead of manually adding hundreds of servers within the Change.

We have like 13 groups that take a couple of hours to update and looking for a working solution to update the CIs in those groups.

 

Thanks!

4 REPLIES 4

kmohammed
Tera Guru

Hi Mark,

 

Short answer: a Dynamic CI Group cannot be driven directly by Active Directory group membership, because a Dynamic group is query-driven — it rebuilds from CMDB fields on the CIs themselves. So for patching, you have two workable patterns, and which one fits depends on whether your 13 groups are Dynamic or static CMDB Groups.

 

Option 1 — Make the AD fact a CMDB fact, then use a Dynamic group (my preferred approach if you can)

If the servers in each AD group share something Discovery already brings into the CMDB — for example an OU, location, support group, operating system, or a tag / custom attribute — build the Dynamic group query on that field instead of on AD membership. The group then refreshes automatically as CIs are discovered and updated, with no sync job to maintain. This is the cleanest option for a repeating patching cycle, but it only works if the AD grouping maps to a reliable CMDB attribute.

 

Option 2 — Sync AD membership into static CMDB Groups on a schedule

If the groups are static CMDB Groups, automate the membership with a scheduled job that runs nightly (and again just before you build the patching Change):

 

1. Get the current members of each AD group — for example through your existing AD/LDAP integration or a MID Server script that calls Get-ADGroupMember. Resolve each member server name to its CI (by name / FQDN) in cmdb_ci_server.

2. Compare that list with the current members of the matching CMDB Group, add the CIs that are new, and remove the CIs that are no longer in the AD group. Log every add and remove so you can audit it before the patch window.

3. Pilot it with one group first and compare the counts against your manual list before you roll it out to all 13 groups.

 

A Flow Designer flow can do steps 1–2 as well (a scheduled trigger, an AD lookup, then a script step to sync the membership), so you do not have to hand-maintain this every cycle — the key is that the sync is driven from a stored list of AD members in ServiceNow, not typed in by hand.

 

One question that will decide the design: are these Dynamic CI Groups, or static CMDB Groups? If they are Dynamic, tell us what distinguishes the servers in one group from the servers in another on the CMDB side (OU, location, tag, etc.) — if that distinction exists in the CMDB, Option 1 will save you the sync job entirely.

 

If this helped, please mark it as Helpful — and if it solved your issue, I'd be grateful if you accepted it as the solution.

HeyMarkWarmack
Tera Expert

Let me do some research in our instance and report back.  Thanks for the detail of the response!

Thanks, Mark — happy to help. Sounds good, I'll be interested to hear what you find in your instance, especially whether those are Dynamic or static groups. Good luck with the research!

HarrisonLee
Mega Contributor

You could use an automated PowerShell script or ServiceNow integration to sync AD group membership with CMDB groups. This would save time and reduce manual errors during monthly patching.