Skip to content

Conversation

@TechTrekwithAJ
Copy link
Contributor

This script automatically finds and cleans up user accounts that meet all of the following conditions:

The user is inactive

The user is locked out

They haven’t been updated in the last 90 days

This code will help to populate the Manufacturer if that empty on CMDB_CI table
This script is used in ServiceNow to automatically fill in the missing manufacturer information for Configuration Items (CIs) in the CMDB (Configuration Management Database).

1. Predefined Mapping:
The script starts with a list of known model names and their corresponding manufacturer names.For example, a model called ThinkPad T14 is made by Lenovo, and MacBook Pro 16 is made by Apple
2. Look Up Manufacturer:
    * It defines a function that looks up the manufacturer’s record in the core_company table (based on the name) and gets its unique ID (sys_id).
3.  Find CIs Missing a Manufacturer:
    * The script goes through all CIs in the cmdb_ci table where the manufacturer field is empty.
4.  Update Missing Manufacturer:
    * For each of those CIs:
        * It checks the model name.
        * If the model is in the predefined mapping:
            * It looks up the correct manufacturer in the core_company table.
            * It updates the CI record by setting the manufacturer field with the correct sys_id.
            * It also logs that the update was successful.
        * If the manufacturer is not found in the system, it logs a warning.
5.  Final Log:
    * After going through all matching CIs, it logs how many records were successfully updated.
Removing roles and group access from dormant users is a critical security and compliance best practice — it reduces the attack surface and prevents unauthorized access.
This script automatically finds and cleans up user accounts that meet all of the following conditions:
* The user is inactive
* The user is locked out
* They haven’t been updated in the last 90 days
@github-actions
Copy link

Thank you for your contribution. However, it doesn't comply with our contributing guidelines.

As a reminder, the general requirements (as outlined in the CONTRIBUTING.md file) are the following: follow the folder+subfolder guidelines and include a README.md file explaining what the code snippet does.

Validation errors:

Folder structure violations found:
 - Move 'Server-Side Components/Scheduled Jobs/ReadME.md' under a valid folder hierarchy (Category/Subcategory/Use-Case/your-file). Files directly inside 'Server-Side Components' or its subcategories are not allowed.
 - Move 'Server-Side Components/Scheduled Jobs/Remove Inactive and locked out users from All Groups and Roles.js' under a valid folder hierarchy (Category/Subcategory/Use-Case/your-file). Files directly inside 'Server-Side Components' or its subcategories are not allowed.

Review your contribution against the guidelines and make the necessary adjustments. Closing this for now. Once you make additional changes, feel free to re-open this Pull Request or create a new one.

@github-actions github-actions bot closed this Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant