Skip to content

Instantly share code, notes, and snippets.

@jlrjr
jlrjr / f0cal-conan-lttng.sh
Created March 11, 2019 20:59
FØCAL install LTTng via Conan
python3 -m venv _venv
source _venv/bin/activate
pip install --upgrade pip # because wheel
pip install conan
conan remote add f0cal https://api.bintray.com/conan/f0cal/conan
conan install lttng-ust/2.10@f0cal/testing
conan install lttng-tools/2.10@f0cal/testing
@jlrjr
jlrjr / okta_bulk_user_id_update.js
Last active December 7, 2016 20:15
Okta ServiceNow ActivityPack Bulk Update User with OktaID
//query Okta for all users (sys_users) that do not have Okta IDs
// this may take a while to run for large user counts
getOktaUserIDs();
function getOktaUserIDs() {
var users = new GlideRecord("sys_user");
if (!users.isValidField("x_okta2_actpack_okta_id")) {
gs.error("Okta ID (x_okta2_actpack_okta_id) does not exist on sys_user table");
return;
}
@jlrjr
jlrjr / myACLUtils.js
Last active June 26, 2018 14:09
Helper class to create default ServiceNow table ACLs for a given table
var table = "";
var roleName = "";
//call is after class definition
var myACLUtils = Class.create();
myACLUtils.prototype = {
initialize: function() {},
createDefaultTableACLs: function(table, roleName) {
@jlrjr
jlrjr / reset_app_sys_fields.js
Last active April 28, 2016 22:19
Reset all records in an ServiceNow application to a given vendor or user name
//run in global scope as background script
/**** set these variables before running ****/
var vendorName = "--CAVUCode--";
var appID = "---AddAppSysIDHere---";
/**** after setting variabless above, uncomment this line to run ****/
//updateAppFiles(vendorName, appID);
function updateAppFiles(vendorName, appID) {
@jlrjr
jlrjr / CreateVulnerabilityCIs.js
Last active April 12, 2016 14:02
Create ServiceNow configuration items from security vulnerability data. Use for populating test data, not for production use.
//create sample CIs based on vul items
//createVulCIs();
linkVulsToCIs();
function createVulCIs() {
var item = new GlideAggregate("sn_vul_vulnerable_item");
item.activeQuery();
item.addNotNullQuery("dns");
item.groupBy("dns");
@jlrjr
jlrjr / PagerDuty_Migration.js
Last active May 25, 2016 01:09
Migration script to move from legacy PagerDuty update set integration to the new Fuji ServiceNow store app
/*
* Must be run from backgroup script as a user with the elevated security_admin role
*/
// migrate incident id values
migrateIncidents();
// migrate group attributes from legacy update set application to the new Fuji store app
migrateGroups();
@jlrjr
jlrjr / app_config_file_uipage.xml
Created October 30, 2015 17:12
ServiceNow UI Page to display application files
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:g2="null" xmlns:g="glide" xmlns:j2="null" xmlns:j="jelly:core">
<!-- get the scope of the current record and list of tables to display-->
<g:evaluate var="jvar_my_scope">
var scope = new GlideRecord("sys_scope"); scope.get("scope", gs.getCurrentScopeName()); scope;
</g:evaluate>
<g:evaluate expression="scope.getDisplayValue()" var="jvar_my_scope_name"/>
<g:evaluate expression="scope.getUniqueValue()" var="jvar_my_scope_id"/>
<g:evaluate expression="gs.getProperty(scope.scope + '.config_file_tables','')" var="jvar_config_tables"/>
@jlrjr
jlrjr / CheckTransformMapChoiceActions.js
Last active November 6, 2015 15:18
ServiceNow background script to check import transform map choice actions
//change to sysid of app you want to scan
var appID = "e32a61c94f198a004f167d2ca310c72a";
reviewTransformChoiceActionsForApp(appID);
function reviewTransformChoiceActionsForApp(appId) {
var entry = new GlideRecord("sys_transform_entry");
entry.addQuery("sys_scope", appId);
entry.orderBy("map");
entry.query();
@jlrjr
jlrjr / generateRandomDate.js
Created April 1, 2013 14:25
Generate Random GlideDateTime for ServiceNow
/**
* Generate a random GlideDateTime
* If start and end are not specified you'll get a random date within the past year
*
* @param [start] GlideDateTime - optionally defines the start of the window
* @param [end] GlideDateTime - optionally defines the end of the window
* @return GlideDateTime
*/
function generateRandomDate(/*[GlideDateTime]*/start, /*[GlideDateTime]*/ end){
var temp = new GlideDateTime();