Things to do with your PDI

A simple list of things to do to your PDI

Things you should do with you PDI when you zboot it.

  1. Create Local Account with your name/email
  1. Lockout all other users
  2. Activate Plugins
  1. Disable any “application” menus you don’t intend to use.
  2. Update dictionary on task.wf_activity to be “active”
  3. Set up Oauth with Github for faster login
  4. Load any update sets/applications/shares you have saved off locally or in git repositories.

Useful Share/Applications/Update Sets

ShareShareGit
XploreShareGithub
UI 16 Developer PatchShareGithub
Upgrade AssistantShare
Code Search Service Portal WidgetGithub
Security Best Practice AuditShare

Background Script To Do This

// This will make a user with and id of slack
// password of password with appropriate roles.
var users = [{
    id: 'jace.benson',
    firstName: 'Jace',
    lastName: 'Benson',
    password: 'slack'
}, {
    id: 'slack',
    firstName: 'slack',
    lastName: 'er',
    password: 'slack'
}];

function createUserWithRoles(userObj) {
    var userGR = new GlideRecord('sys_user');
    if(userGR.get('user_name',userObj.id)) {
        // donothing
    } else {
        userGR.newRecord();
    }
    userGR.setValue('user_name', userObj.id);
    userGR.setValue('active', 'true');
    userGR.setValue('first_name', userObj.firstName);
    userGR.setValue('last_name', userObj.lastName);
    userGR.setValue('locked_out', false);
    userGR.setValue('password_needs_reset', 'true');
    userGR.setDisplayValue('user_password', userObj.password);
    userGR.setWorkflow('false');
    gs.print('userObj.id: ' + userObj.id);
    gs.print('userObj.id: ' + userObj.password);
    var userSysId = userGR.update();
    giveRole(userSysId, 'admin');
    giveRole(userSysId, 'security_admin');
}
function giveRole(userId, roleName) {
    var give = new GlideRecord('sys_user_has_role');
    give.newRecord();
    give.setValue('user', userId);
    give.setDisplayValue('role', roleName);
    give.insert();
}
function lockOutEveryoneElse() {
    var usersToLockOut = new GlideRecord('sys_user');
    usersToLockOut.addEncodedQuery('sys_created_on<javascript:gs.beginningOfToday()');
    usersToLockOut.query();
    while (usersToLockOut.next()) {
        usersToLockOut.setValue('locked_out', true);
        usersToLockOut.update();
    }
}
users.map(function(user){
    createUserWithRoles(user);
});
lockOutEveryoneElse();

Edit this page

Avatar
Jace Benson
ServiceNow Developer

ServiceNow is my day job, JAMStack is my passion.