Skip to content

Commit c95a11c

Browse files
committed
added user account cleanup script
1 parent 63dc0d4 commit c95a11c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

UserAccountCleanup/readme.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# User Account Cleanup
2+
3+
This script automatically disables user accounts that have been inactive for more than six months, maintaining a secure and manageable user database.
4+
5+
## Usage
6+
- Use this script in a scheduled job to regularly clean up inactive accounts.
7+
- Modify the `last_login_time` query as needed for different inactivity thresholds.

UserAccountCleanup/script.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(function cleanupInactiveUsers() {
2+
// Query for users inactive for over 6 months
3+
var user = new GlideRecord('sys_user');
4+
user.addEncodedQuery('last_login_timeRELATIVELE@dayofweek@-180');
5+
user.query();
6+
7+
// Disable each inactive user account
8+
while (user.next()) {
9+
user.active = false;
10+
user.update();
11+
}
12+
})();

0 commit comments

Comments
 (0)