Reset Passwords of Users from Multiple Domains using PowerShell Script

If you have ever worked as Windows Administrator in multi-domain environment, you would know the pain of switching to different domain controllers for resetting user’s passwords. Normally, IT admins take RDP of respective domain controller to reset passwords of users in that domain. However, this process takes time and becomes hectic if you have to reset passwords of multiple users from multiple domains.

However, you can manage multiple domains in Active Directory Administrative Center. But that requires you to setup trusts between domains. Detailed information can be found here. This problem can be solved by using PowerShell script. In this tutorial, we are going to share with you a PowerShell script that allows you to reset or change passwords of users from multiple domains from single place.

SEE ALSO: How to Get Local User Accounts from Domain Computers using PowerShell Script?

Features & Requirements of Script

Best part of this script is that your system doesn’t need to be joined into any of the domains. But all required domains must be reachable from your computer. This scripts has some features as well as some limitations. Here is brief overview:

Features:

  • Reset passwords of users in multiple domains.
  • Switch between domains from same console.
  • Admin credentials validation check.
  • User Account validation check.
  • Doesn’t require to be run on Domain controllers.
  • User machine need not be joined to any domain.

Requirements:

  • If you are running this script on your client system, RSAT tools need to be installed.
  • Target domain must be reachable from your system. So, you should open required ports at Firewall end first.
  • Create manual DNS entries for each domain in hosts file to resolve target domain without problems.
  • You must have Admin Credentials of all the domains for which you want to reset passwords.
  • This script doesn’t have password complexity check for new password. Make sure you enter a valid password.

Reset Passwords of Users from Different Domains using PowerShell Script

Let’s discuss the functioning of the script in some details. This script, first asks the user to enter the domain name which contains the target user account. Then, script asks for Admin credentials which are used for resetting user’s password in that domain. After that script prompts for user details whose password needs to be reset.

Here are detailed steps explaining the functioning of the script. Script download link is available at the end of the post.

Step 1: Create Shortcut to Launch the Script

You can run the script in PowerShell as well but for the sake of simplicity and ease of access, we are going to create a shortcut to launch the script.

So, first of all, copy the script to a folder on your computer, then right-click in blank space and select New > Shortcut.

Right-click and select New > Shortcut
Right-click and select New > Shortcut

Step 2: Set Shortcut Parameters

New shortcut window will open. Copy following code into the location bar and click Next:

powershell.exe -File "PathToScript\ScriptName.ps1" -ExecutionPolicy Bypass

Replace PathToScript\ScriptName.ps1 by actual path of the script as shown below.

Set shortcut parameters for the script
Set shortcut parameters for the script

In the next window, provide a name for the shortcut and click Finish.

Provide the name for shortcut
Provide the name for shortcut

Step 3: Clear ‘Start in’ Parameter of Shortcut

Shortcut for running the script is ready but we still need to make some changes to it. Otherwise, the script will fail to run because by default, PowerShell will run the script in C:\Windows\System32 directory which requires Admin privileges. So, to fix this, right-click the shortcut and select Properties.

Open Shortcut's Properties
Open Shortcut’s Properties

In Properties window, clear the path provided in “Start in:” field and click OK.

Clear "Start in:" Field to reset password of multiple users from multiple domains
Clear “Start in:” Field and click OK

SEE ALSO: How to Create Bulk Users in AD using PowerShell Script?


Step 4: Run the PowerShell Script to Reset User Password

Script is ready to rock! Simply, double-click the shortcut we just created. Script will open in CMD window. You don’t need to run the script with Admin privileges, it works fine with standard user rights.

Script will ask you to enter the domain name first. So, enter the domain name to reset passwords of users from that domain.

Run PowerShell script to Reset Passwords of users from Multiple domains
Run PowerShell script to Reset Passwords of users from Multiple domains


Step 5: Provide the Domain Name and Admin Credentials

It’s time to enter the domain name where target user (whose password you wish to reset) exists. Remember, you will require Admin credentials for that domain.

Enter the domain name and press Enter (you can use full domain name or NetBIOS name, both works fine). A prompt will show up asking for Admin credentials. Provide correct Admin credentials to continue. If you fail to provide correct credentials three times, script will exit.

Provide Domain Name and Admin credentials
Provide Domain Name and Admin credentials

Step 6: Reset User Password from Multiple Domains

After successfully validating Admin credentials, script will continue. Next, script will ask you for the username (samAccountName) of the user whose password you want to reset.

After you provide the username, script will check the username in target domain. If script finds the username successfully, it will prompt for the new password for selected user. Otherwise, script will prompt 3 times for valid username and failing which it will exit with a warning message.

Enter the username of the user to Reset the password
Enter the username of the user to Reset the password

Now provide new password for selected user. You will need to enter the password twice. If passwords don’t match, script will ask you 3 times before displaying exit choices.

After you provide valid password, the script will reset the password of selected user and provide options for proceeding further.

User Password Reset Successfully
User Password Reset Successfully

SEE ALSO: A to Z list of Windows CMD Commands.


Step 7: Select Options to Proceed Further

After successfully resetting user’s password, you will see 3 options. You can choose any of them depending on your requirement. So, if you want to reset password of another user in same domain, press ‘1‘. Script will show you a prompt for providing username.

Enter 1 to Reset user Password in same Domain
Enter 1 to Reset user Password in same Domain

Second options is for pressing ‘2‘ to select new domain. You will be prompted to enter the domain name.

Press 2 to Change the Domain
Press 2 to Change the Domain

Third option is ‘press any other key‘ to exit the script. If you press anything except ‘1‘ or ‘2‘, script will exit with a message.

Press any key except 1 & 2 to exit the script
Press any key except 1 & 2 to exit the script

Download the PowerShell Script

Click following link to download the script.


Use PowerShell Script to Reset Passwords in Multiple Domains

Above tutorial explained the functioning of the PowerShell script to reset user’s passwords in multiple domains without logging into each domain’s AD servers. We hope this script will make lives of Windows Administrators easier.

If you find this script useful, make sure to share this article with your friends. Also if you have any queries or suggestions, feel free to share in comments below. You can download the script from the link provided below.

Editorial Staff

Hi there, we are the editorial staff at HELLPC. We are a team of funny and technical people. Feel free to get in touch with us via Contact-Us page.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button