Sunday, May 9, 2021
HomeBloggingHow to Force Reset G Suite Users' Passwords with Apps Script

How to Force Reset G Suite Users’ Passwords with Apps Script

- Advertisement -
- Advertisement -

You can utilize Google Apps Script to naturally reset the secret phrase of clients in your GSuite area. This content must be executed under the Suite administrator account. You additionally need to empower the AdminDirectory Advanced Service in your Apps Script Editor.

You can constrain reset passwords of individuals from a specific gathering in your association or determine a rundown of email addresses and the Google Script will utilize the AdminDirectory administration to change the secret key of indicated clients.

const getGroupMembers_ = groupEmail => {
  var emails = [];
  var pageToken;
  do {
    const { members = [], nextPageToken } = AdminDirectory.Members.list(
        maxResults: 200,
        pageToken: pageToken
    members.forEach(member => {
      if (member.status === "ACTIVE") {
    pageToken = nextPageToken;
  } while (pageToken);
  return emails;

const sendEmail_ = (emailAddress, password) => {
    to: emailAddress,
    cc: "",
    subject: `Password changed for ${emailAddress}`,
    body: `The GSuite admin has changed your Gmail password to ${password}`

const changePassword_ = emailAddress => {
  const temporaryPassword = Utilities.getUuid();
      password: temporaryPassword,
      changePasswordAtNextLogin: true
  sendEmail_(emailAddress, temporaryPassword);

const resetUserPasswordsForGroup = () => {
  const groupEmail = “”;
  const members = getGroupMembers_(groupEmail);
  members.forEach(member => changePassword_(member));

const resetGSuitePasswordForUsers = () => {
  const members = [
  members.forEach(member => changePassword_(member));

Change G Suite Passwords Periodically

You can create a time-based trigger in Google Scripts to automatically run the reset function at specific intervals (like update password on the first of every month).


The Google Script is written in ES6 with V8 runtime. If V8 is not enabled for your GSuite account, replace the manifest appsscript.json file with this:

  "timeZone": "Asia/Kolkata",
  "dependencies": {
    "enabledAdvancedServices": [{
      "userSymbol": "AdminDirectory",
      "serviceId": "admin",
      "version": "directory_v1"
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8"

Empower Admin Directory Service

To utilize the Advanced Directory progressed Google administration inside your Google Apps Script project, adhere to these guidelines:

Open the Google Script, select the Resources menu and afterward pick Advanced Google administrations.

In the Advanced Google Service discourse that shows up, flip on/off switch close to the Admin Directory administration

Snap OK to save your changes.

- Advertisement -
I am a Multimedia artist, I am born and based on Dewas (M.P), I am working as a freelancer with various brands and different country. My expertise are Graphics designing, motion graphics, 2d/3d animation, advertising videos, cartoons designing, all types of packaging and branding designing, digital marketing, SEO, design website and app Developments etc...

Leave a Reply

- Advertisment -
- Advertisment -

Most Popular

- Advertisment -