Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var user = new GlideRecord("sys_user"); // Glide to user table
user.addActiveQuery();
user.addEncodedQuery("u_service_account=true"); // Adding encoded query to filter the only Service Account
user.query();
while (user.next()) {
var arr = []; // Definind an empty array
arr.push(user.user_name); // pushing all he usernames with in the array
for (var i = 0; i <= arr.length - 1; i++) {
var userID = arr[i];
var query1 = "sys_created_onRELATIVELT@dayofweek@ahead@40^sys_created_by=" + userID; // creating a dynamic query to check if the account has any transaction in last 40 days on transaction table.
var tranSaction = new GlideRecord("syslog_transaction"); // Glide to the tranaction table
tranSaction.addEncodedQuery(query1); // adding an query1
tranSaction.query();
tranSaction.orderByDesc("sys_created_on");
if (!tranSaction.next()) {
gs.print(arr); // this will print only user names which does not have any transaction in last 40 days on log transaction table.
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This schedule job script will help to auto disable the service accounts which has not been logged in or used for last 40 days. This can be helpful for those who are looking to disable the accounts based on some certain time period.
Loading