Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thisnameissoclever/2a71745e751a882e04e4235a49b1bf41 to your computer and use it in GitHub Desktop.
Save thisnameissoclever/2a71745e751a882e04e4235a49b1bf41 to your computer and use it in GitHub Desktop.
ServiceNow - Deploy sub-prod configuration automatically
function deployDevConfig() {
_deactivateAllNonAdmins();
_disableEmails();
_setHeaderName();
_deactivateLDAPServers();
}
function _deactivateAllNonAdmins() {
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('roles!=admin');
gr.query();
gr.setValue('locked_out', 'true');
gr.updateMultiple();
return true;
}
function _disableEmails() {
//Disable inbound emails
gs.setProperty("glide.email.read.active", false);
//Disable outbound emails
gs.setProperty("glide.email.smtp.active", false);
//set test address to forward all emails to (if sending it re-enabled)
gs.setProperty("glide.email.test.user", '[email protected]');
return true;
}
function _setHeaderName() {
gs.setProperty("glide.product.description", "SUB-PROD Instance");
return true;
}
function _deactivateLDAPServers() {
var grLDAP = new GlideRecord("ldap_server_config");
grLDAP.query();
grLDAP.setValue('active', 'false');
grLDAP.updateMultiple();
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment