File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Specialized Areas/Fix scripts/Group Sync Script Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ ServiceNow Fix Script - Group Role Synchronization
2+ Overview
3+
4+ This Fix Script automatically validates and synchronizes user roles with their assigned groups in ServiceNow.
5+ It checks if every user in the target groups has all the roles assigned to that group.
6+ If any roles are missing, the script re-adds the user to the group, ensuring all inherited roles are correctly applied.
7+
8+ How It Works
9+
10+ Identify Groups
11+ The script starts by reading the list of sys_ids of the target groups.
12+
13+ Fetch Group Roles
14+ It retrieves all the roles assigned to each group from the sys_group_has_role table.
15+
16+ Check Each User
17+ For each user in the group (sys_user_grmember), it fetches their assigned roles from sys_user_has_role.
18+
19+ Detect Missing Roles
20+ Compares the user’s roles with the group’s roles.
21+ If any group role is missing for a user:
22+
23+ Removes the user from the group.
24+
25+ Re-adds the user to the group, triggering ServiceNow’s role inheritance process.
26+
27+ Logs
28+ The script logs all actions using gs.info() for easy monitoring in the system logs.
You can’t perform that action at this time.
0 commit comments