- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
If you're like us, you're always struggling to keep the number of licenses you need under control. I was recently tasked with this since we were so far over our license limits. I made a quick script in order to figure out who were just the "ceremonial" approvers who wanted the honor of an approval role, same thing for the ITIL roles. What this background script does is iterate through change requests, change tasks, incidents, problems and approvals and grab the assigned_to and approver names, before deduping and printing them to the log.
WARNING: if you have a huge amount of rows in those tables you could bring your instance to its knees, in which case be sure and get a clone to your test instance first, or add some query parameters to just grab the last weeks or months of records.
var tables = ['change_request','change_task','incident','problem','sysapproval_approver'];
var licenses = [];
for(var i=0;i<tables.length;i++) {
var rec = new GlideRecord(tables[i]);
rec.query();
while (rec.next()) {
if(typeof rec.assigned_to != "undefined" && rec.assigned_to != '')
licenses.push(rec.assigned_to.getDisplayValue());
if(typeof rec.approver != "undefined" && rec.approver != '')
licenses.push(rec.approver.getDisplayValue());
}
}
var arrayUtil = new ArrayUtil();
licenses = arrayUtil.unique(licenses);
for(var i=0;i<licenses.length;i++) {
logMe(licenses[i]);
}
function logMe(message) {
if(gs) {
gs.addInfoMessage(message);
} else {
log.info(message);
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.