Skip to content
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Thrizvi - as mentioned recent PRs as well. Please add ".js" to your respective script file name

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var gr = new GlideRecord('sys_user');
gr.addQuery('active', false);
gr.query();

while (gr.next()) {
var login = new GlideRecord('syslog');
login.addQuery('user', gr.sys_id);
login.query();

if (!login.hasNext()) {
gs.print('Deleting inactive user: ' + gr.name);
gr.deleteRecord();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

Delete Inactive Users Without Login History

This ServiceNow background script identifies and deletes inactive users who have never logged into the system. It's useful for cleaning up unused accounts and maintaining a secure, lean user base.

- Identify users marked as `active = false`
- Check if they have any login records in the `syslog` table
- Delete users who have no login history
Loading