• Home
  • PowerShell
  • PowerShell Script to Reset User's Password in Google Workspace

PowerShell Script to Reset User's Password in Google Workspace (Google Apps)

The PowerShell script provided here resets a user's password in Google Workspace. ADSelfService Plus, an Active Directory (AD) self-service password management, and single sign-on solution, offers the Password Reset feature that allows users to reset their AD passwords. It also offers the Password Synchronization feature that syncs users’ passwords and any changes to it with their user accounts in applications like Google Workspace. When both these features are configured, users can use the same password to log into Google Workspace and their AD domain, and can reset this password without help desk intervention. Here is a comparison between resetting user's Google Workspace passwords using PowerShell and ADSelfService Plus.

With PowerShell

Google Workspace passwords can be reset using a set of PowerShell cmdlets called gShell. Run the following script to reset a user's Google Workspace password:

$scriptBlock = {
Import-Module gShell

$userID = "%mail%" # TODO: modify me
$newPassword = "Password" # TODO: modify me

Set-GAUser -UserKey $userID -NewPassword $newPassword
}

try
{
Invoke-Command -ComputerName localhost -ScriptBlock $scriptBlock -ErrorAction Stop
}
catch
{
$Context.LogMessage("An error occurred when reseting password for user. Error: " + $_.Exception.Message, "Warning")
}
With ADSelfService Plus

ADSelfService Plus's Password Reset feature allows users to reset their Google Workspace passwords without any help-desk intervention. This reduces the workload of help desk administrators and improves the user's productivity.

Feature configuration is as simple as:

  • Creating an ADSelfService Plus policy.
  • Specifying the users for the policy.
  • Selecting Password Reset and other self-service actions for respective users.

The Password Synchronization feature synchronizes the changes made to a user's AD password with other integrated applications like Google Workspace, Office 365, Salesforce, and much more.

Configuration involves:

  • Selecting the application for which passwords are to be synced.
  • Selecting the right ADSelfService Plus policy whose users' passwords are to be synced.

When both these configurations are set to be true, users can reset their Google Workspace passwords, and it will be synced with their AD domain accounts automatically.

Screenshots:

"The ability to sync passwords on 2 platforms and change it in one place. Giving IT more time to focus on other things other than password issues."

-Andrés S

Rated 5/5 on Capterra

Advantages of ADSelfService Plus:

Using PowerShell to reset passwords in Google Workspace

Step 1: Install the Google Admin SDK module

Ensure you have the required module by running the script below.

Install-Module GoogleWorkspace -Scope CurrentUser

Step 2: Authenticate to Google Admin API

Connect using API credentials. This allows PowerShell to communicate with Google Workspace.

Connect-GoogleWorkspace -ClientID "your-client-id" -ClientSecret "your-secret-key"

Step 3: Reset a user’s password

Set a new password for a specific user. The script below updates the password for user@example.com.

Set-GoogleWorkspaceUserPassword -User "user@example.com" -NewPassword "NewSecurePassword!"

Step 4: Notify the user

Send an email notification about the password change to ensure users are informed about the change.

Send-MailMessage -To "user@example.com" -From "admin@yourdomain.com" -Subject "Password Reset" -Body "Your password has been reset. Please change it upon login."

FAQs

1. How can I reset a Google Workspace user’s password?

Use Google’s API with PowerShell to reset a Google Workspace user’s password.

Set-GoogleUserPassword -User user@domain.com -NewPassword "NewPass@123"

2. Can I force users to change passwords at the next login?

Yes, you can force users to change passwords at the next login by modifying user settings in Google Admin Console.

3. Can I bulk reset passwords for multiple users?

Yes, you can bulk reset passwords for multiple users with Google API scripting.

Empower users to reset their Google Workspace passwords.

ADSelfService Plus trusted by

A single pane of glass for complete self service password management
Email Download Link