Skip to content

added user account cleanup script #1603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions UserAccountCleanup/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# User Account Cleanup

This script automatically disables user accounts that have been inactive for more than six months, maintaining a secure and manageable user database.

## Usage
- Use this script in a scheduled job to regularly clean up inactive accounts.
- Modify the `last_login_time` query as needed for different inactivity thresholds.
12 changes: 12 additions & 0 deletions UserAccountCleanup/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function cleanupInactiveUsers() {
// Query for users inactive for over 6 months
var user = new GlideRecord('sys_user');
user.addEncodedQuery('last_login_timeRELATIVELE@dayofweek@-180');
user.query();

// Disable each inactive user account
while (user.next()) {
user.active = false;
user.update();
}
})();
Loading