Force Google Apps users to change password periodically
I found this Stack Overflow post in which it is asked to force the Google Apps Users to change the password periodically. I quickly created an script which will allow Google Apps admin to force the users to Change the password.
Open this link to make a copy of the script file and follow the instructions given in below screenshot. Step 2 shows the frequencywhich can be changed as per your organization requirement.
Note : Script can be run only under Google Apps Admin's authority
Google Apps Script
function invalidatePass() {
//Create logs
Logger.log('Execution started');
Logger.log('Following users forced to change password on next login');
Logger.log('--------------------------------------------------------');
var mailSent = false;
try {
//get all users in domain
var users = UserManager.getAllUsers();
//iterate for each user
for(var i in users){
//set the user to change password on next login
users[i].setChangePasswordAtNextLogin(true);
//Put the email of the user in log
Logger.log(users[i].getEmail())
}
}
//Catch if any error occurs
catch(e){
//Log the error
Logger.log('--------------------------------------------------------');
Logger.log('Error occured: '+e.message);
//Send an email to yourself with logs
GmailApp.sendEmail(Session.getEffectiveUser().getEmail(), 'Log for User Pass Change Script : Error occured', Logger.getLog());
mailSent = true;
}
if(!mailSent){
//if execution successful
Logger.log('--------------------------------------------------------');
Logger.log('Execution ended. Script completed successfully');
//Send an email to yourself with logs
GmailApp.sendEmail(Session.getEffectiveUser().getEmail(), 'Log for User Pass Change Script: Successful', Logger.getLog());
}
}