Link to home
Start Free TrialLog in
Avatar of Navishkar Sadheo
Navishkar SadheoFlag for South Africa

asked on

Reset multiple AD accounts in an OU with different passwords?

Dear Experts

It is possible to reset the passwords of multiple AD accounts in a particular with a different password for each user? I can supply a password list in a CSV file or is there a way to have the system generate random passwords for each account and put those in a CSV. Appreciate any advice.
Avatar of Hello There
Hello There

You can use Powershell.

An example here:
https://community.spiceworks.com/topic/370755-reset-passwords-using-a-utility-for-ad 
CSV:
Username,Password
"User1","Password1"
"User2","Password2"

Open in new window

PowerShell script:
$UserPwds = Import-CSV C:\path\to\CSV\Users.CSV
ForEach($User in $UserPwds)
{
   Set-adaccountpassword $User.UserName -reset -newpassword (Convertto-Securestring -asplaintext $($User.Password) -force)
}

Open in new window


If you have a text file (d:\usernames.txt) with
--
user1
user2
...
--
then this one-liner Batch will do and create an outputfile with all randomly generated passwords
for /f %a in (d:\usernames.txt) do net user %a /random /domain>>d:\out.txt

Open in new window

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.