This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Some times it is nice to know if you script is still running.... | |
*/ | |
var deleted_count = 0; | |
// Some GlideRecord stuff herre | |
while (pgr.next()) { | |
//Some processing stuff here | |
deleted_count++; | |
if (deleted_count % 100 == 0)//Report out every hundredth time | |
gs.warn("Deleted so far: " + deleted_count); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Use this instead: | |
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1349923 | |
I quickely built this then notices the KB... sight... | |
This will need to be a FIX Script that will need to be run in the background | |
*/ | |
var delete_count = 0; | |
var count = 0; | |
var table = 'sn_sec_cmn_src_ci'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl "https://<your_instance_name>.service-now.com/api/now/table/incident?sysparm_limit=1" \ | |
--request GET \ | |
--header "Accept:application/json" \ | |
--user 'user_name':'password' | |
curl "https://<your_instance_name>.service-now.com/api/now/table/incident?sysparm_limit=1" --request GET --header "Accept:application/json" --user 'abel.tuter':'xxxxxx' | |
//Notes | |
Build your request in REST API Explorer | |
In the "Code Samples" section select cURL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
If you need to update your remediation targets, create a Fix Script in the Vulnerability Response scope, | |
craft your Encoded Query, test, test, and then valideate. | |
*/ | |
var vit = new GlideRecord("sn_vul_vulnerable_item"); | |
//This Encoded Query is just an example | |
vit.addEncodedQuery('active=true^risk_rating=2^risk_score>=80^ORrisk_score<=49^NQactive=true^risk_rating=3^risk_score>=50^ORrisk_score<=29^NQactive=true^risk_rating=4^risk_score>=30^ORrisk_score<=0^NQactive=true^risk_rating=5^risk_score>0'); | |
vit.setLimit(1);//Remove before flight, for people who don't read directions | |
vit.query(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
If you need to force a recalcuation on a VIT (or set of VITS) then place this script in a Fix Script and execute. | |
Note: The Fix Script should be in the Vulnerability Response Application Scope | |
Use Case: | |
-- Force a change on VIT to test a change in *DEV* | |
-- Force a change to existing data becouse your model changed | |
****TEST**** then ****RETEST*** AND ***VALIDATE*** before proceding off your DEV enviroment with this script. There is no undo button. | |
*/ | |
var vit = new GlideRecord('sn_vul_vulnerable_item'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Use Case: Provide an "Is Dynamic" option for the "Company" field on a Condition Builder | |
#1 | |
Client Callable Script Include | |
Global Scope, Accessable All Scopes | |
Related ACL: | |
type: client_callable_script_include | |
operation: Execute | |
name: DynamicFilters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
OnBefore Transform Script to support a Transform Map. (I.E. Fields that need to be transformed before insert) | |
Use Case | |
1. Using the ServiceNow Table API insert a "vulnerability finding" into a custom table extened from "Import Set Row" | |
2. Automaticaly Run the Tranfrom Map on each insert of a record/row and insert the data on the vulnerable item table | |
Note: This is intended for low volume inserts into the VIT table | |
*/ | |
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Vulnerability Response Assignment Rule -> Assign using Script | |
current.assignment_group = new global.VRUtil().arSVClookup(current.cmdb_ci); // ***Example Script*** | |
Note: | |
1. current.assignment_group #Note: If the lookup fails you ***NEED*** to return a default assignment group! | |
2. current.cmdb_ci you can use any property that "current" knows about, but typically its the CI | |
*/ | |
//Script Include, Example Method: | |
arSVClookup: function(current_rule) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fileName = 'Incidents.csv'; | |
var csvData = ''; //The variable csvData will contain a string which is used to build the CSV file contents | |
var Headers = ["Number","Caller","Short Desc","Assignment Group", "Assigned To"]; | |
//Build Header / End First Row | |
for (var i = 0; i < Headers.length; i++) { //Build the Headers | |
csvData = csvData + '"' + Headers[i] + '"' + ','; | |
} | |
csvData = csvData+"\r\n";//End first row |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Testing the CMDB Class of some made up hosts on my instance | |
//Positive Test | |
var NotThere = 'b69715668326e110b356df647daad3f8';//cmdb_ci_vm_object | |
var chrisOne = '5f7dfd9cc0a8010e00ab58006f14bdc5';//cmdb_ci_unix_server | |
var answer = false; | |
var rec = new GlideRecord('cmdb_ci'); | |
rec.get(chrisOne); | |
//test = 'manufacturer=b7e7c073c0a801690143e7b7d29eb408'; //Works | |
//test = 'sys_class_name=cmdb_ci_unix_server'; //Works | |
//test = 'sys_class_nameINSTANCEOFcmdb_ci_unix_server'; //Works |
NewerOlder