sixone74
2018-08-09T16:13:23Z

Clone Cleanup Script.js

| var gr = new GlideRecord('u_focus_group');
| var strQuery = 'u_expiration>=javascript:gs.beginningOfToday()^u_active=true';
| gr.addEncodedQuery(strQuery);
| gr.query();
|
| while (gr.next()) {
|
| // Reset user profile and password
| var gruser = new GlideRecord('sys_user');
| gruser.get(gr.u_user);
|
| if (gruser.active == false) {
| gruser.active = true;
| gruser.user_password = '123456';
| gruser.password_needs_reset = true;
| gruser.locked_out = false;
| gruser.update();
| }
|
| // Reset group assignments
| var arr = gr.u_groups.split(',');
|
| for(i = 0; i < arr.length; i++){
| var grmember = new GlideRecord('sys_user_grmember');
| grmember.initialize();
| grmember.user = gr.u_user;
| grmember.group = arr[i];
| grmember.insert();
| }
| }
|
| // Disable scheduled jobs
| var gr = new GlideRecord('sysauto');
| gr.get('7380c7a913909740f8cb7e276144b06b'); // Inactive accounts 15 Days
| gr.active = false;
| gr.update();
|
| var gr = new GlideRecord('sysauto');
| gr.get('64b52d1e13692a009a8536666144b02f'); // Inactive accounts 30 Days
| gr.active = false;
| gr.update();
|