How to disable a user if the last login time is greater than 90 days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2022 08:27 PM
Hi,
We have a requirement to disable or deactivate the users in ServiceNow if their last login time is greater that 90 days.
Is this something which we can do with a script?.
regards,
Raghesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 12:34 AM
Hi
Thank you so much for the steps, I will try this and let you know.
regards,
Raghesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 12:36 AM
Sure do keep posted.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2022 09:52 PM
Hi,
You can also use scheduled job for this. Please refer below script:
var gr = new GlideRecord('sys_user');
gr.addActiveQuery();
gr.addEncodedQuery('last_login<=javascript:gs.beginningOfLast3Months()');
gr.query();
while (gr.hasNext()) {
if (gr.next()) {
gr.active = false;
gr.update();
}
}