File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change
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.
Original file line number Diff line number Diff line change
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
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments