Skip to content

Instantly share code, notes, and snippets.

@mtcoffee
mtcoffee / CreateSeleniumServiceNowIncident.py
Last active August 27, 2023 22:10
CreateSeleniumServiceNowIncident
import sys
if len(sys.argv) < 4:
warning = """
Please provide 3 parameters in the format "instancename username password"
e.g. dev1234 itiluser itiluserpassword
"""
print(warning)
sys.exit()
sninstance = "https://" + sys.argv[1] + ".service-now.com"
@mtcoffee
mtcoffee / nesssus_servicenow.js
Created July 28, 2023 01:15
Nessus Scanner API Query ServiceNow background script
/*
MID SERVER WILL NEED TO TRUST YOUR CERTIFICATE OR YOU CAN UPDATE MID CERTIFICATE POLICY FOR Intranet
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0864769
*/
var username = 'admin';
var pwd = 'pass';
var nessusHost = 'secops.domain.home';
var scanName = 'My Scan for Lab';
var midserver = 'winmid01';
@mtcoffee
mtcoffee / pre_processor.js
Created July 26, 2023 20:49
SN Certmgmt exclude pre processor
function checkIfRecordExists(payloadItem) {
var certGr = new GlideRecord('cmdb_ci_certificate');
certGr.addQuery('fingerprint', payloadItem.values['fingerprint']);
certGr.query();
return certGr.next() ? certGr : "";
}
var rtrn = {};
//parsing the json string to a json object
var target = new GlideRecord('sys_email');
target.initialize();
target.type = 'received';
target.subject = "Test Email Subject";
target.recipients = "itdept@domain.com";
target.origemail = "bob.smith@domain.com";
target.body = "sample email body for description";
target.body_text = "sample email body for description";
target.headers = "From:Bob Smith <bob.smith@domain.com> \
To:itdept@domain.com \
<#
.DESCRIPTION
To silently install the ServiceNow MID Server on a Windows system.
Place the file on the target MID Server host machine, update the variables at the top
and run it in PowerShell.
#>
$MSI_FILE_NAME = "C:\temp\winmid.msi"
$INSTALL_LOCATION = "C:\winmid"
$INSTANCE_URL = "https://dev1234.service-now.com/"
@mtcoffee
mtcoffee / gist:e5f6b9167d308d5464e8664488fef082
Created July 4, 2021 22:11
ServiceNow conditionally customize subject of email
<mail_script>
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery("sys_id", current.request_item);
ritm.query('cat_item.name', 'Standard Laptop');
ritm.query();
if (ritm.next()) {
photoshop = ritm.variables.photoshop;
email.setSubject("New Laptop requested and photoshop is set to " + photoshop + " " + current.number);
}
</mail_script>
@mtcoffee
mtcoffee / add RITM variables to task
Created July 4, 2021 22:02
mail script to add ServiceNow RITM variables to Task
//custom function to retrieve all variables from a RITM and print in email
//https://community.servicenow.com/community?id=community_question&sys_id=c8eff1461b4b6050ed6c9979b04bcb59
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
template.print("Summary of Related Requested item:<br />");
@mtcoffee
mtcoffee / add RITM variables to request
Created July 4, 2021 21:57
mail script to add ServiceNow RITM variables to Request
//custom function to retrieve all variables from a RITM and print in email
//https://community.servicenow.com/community?id=community_question&sys_id=c8eff1461b4b6050ed6c9979b04bcb59
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
template.print("Summary of Requested items:<br />");
#!/bin/bash
#reference - stolen from https://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html
#This script should run on any Linux host and has no hard coded parameters
#set percentage to trigger alert
threshold=80
emailaddress=youremail@yourdomain.com
#important****the first line will exclude filesystems with specified strings******
df -PH | grep -vE '^Filesystem|tmpfs|cdrom|nashome' | awk '{ print $5 " " $1 " " $6 }' | while read output;
do
echo $output
@mtcoffee
mtcoffee / drop-public-synonyms.sql
Created September 8, 2017 18:12
PL/SQL Script to delete all public synonyms for a schema
SET serveroutput ON
BEGIN
FOR cur_syn IN (SELECT synonym_name
FROM all_synonyms
WHERE table_owner = upper('schema_user'))
LOOP
BEGIN
EXECUTE IMMEDIATE ('drop public synonym ' || cur_syn.synonym_name ||' ');
EXCEPTION
WHEN OTHERS