4 tasks I do to my Personal Developer Instance (PDI)

Create a personal admin account, lockout other accounts, and set up and plugins you need.

  1. Create Local Account with your name/email

    • Give your account admin and security_admin roles
    • Script To do this
  2. Lockout all other users

  3. Activate Plugins

    • User Registration Request
    • App Engine Studio
  4. Load any update sets

Update Sets

ShareGit
XploreGithub
Code Search Service Portal WidgetGithub

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();
function activatePlugins(){
var plugins = [];
plugins.push('com.snc.user_registration');
plugins.push('com.snc.app-engine-studio');

var main = new GlideMultiPluginManagerWorker();
main.setPluginIds(plugins);
main.setProgressName("Plugin Installer");
main.setBackground(true);
main.start();
}
activatePlugins();