Active Directory: Changing passwords for users in bulk using a .csv file
Many accounts in your AD might need a password change. What if you want to do this in bulk ?
First, we need to the userlist. Depending on your requirements we need to get a list of users (specifically samaccountname). For random password generation I recommend using http://manytools.org/network/password-generator/ as it can generate up 1000 for free.
Here is what my UserList.csv look like:
sAMAccountName,Password test1,gqLfZub$OtO#dBg test2,6eXq78gTyx$YjmM test3,ZNgl!KdYo7U6yzR test4,voiIs!TISw!Wcyc test5,W7ZBTAe7CWcFzyn test6,BykgCY5b*NGFO5! test7,3ApLlchwgRQwf1P test8,9jZvvR2$wDggf3M test9,*QCDjcgnNLkBDP1 test10,sZpvUnvjJxAE9HE test11,$C8TX!tcS3d#MjK test12,Pzw*aH6zjpOx8Wj test13,XmfIPiIz82!!X77 test14,ri!!hQX!w!FSZuI test15,S0Gzf6fEUsG!4Ib test16,Kj8s!vy94S!ozLJ test17,PzFzjP7obALeuWa test18,Ri5V2laxxck6Rgg test19,Rw8KcX*FoMT#gr1 test20,QDndAgzdYo5CYX!
Make sure you do the following on a domain controller or connecting to your domain controller via PS-remote with elevated permissions.
Run this in PowerShell (Open PowerShell in Admin Mode)
PowerShell:
Import-Module Active Directory
$Resetpassword = Import-Csv "c:\_Scripts\UserList.csv"
foreach ($Account in $Resetpassword) {
$Account.sAMAccountName
$Account.Password
Set-ADAccountPassword -Identity $Account.sAMAccountName -NewPassword (ConvertTo-SecureString $Account.Password -AsPlainText -force) -Reset
}
[su_note note_color=”#fafae8″]-Reset
Specifies to reset the password on an account. (User is not prompted to change password).
To use this parameter, you must set the -NewPassword parameter.
You do not need to specify the -OldPassword parameter.
[/su_note]
Author
Related Posts
Get all the domains controllers in the AD forest along with their current FSMO roles
In a large enterprise an admin would need to keep track of all the domains in a AD forest, the domain names,...
Read out all
Force synchronization for DFSR-replicated SYSVOL
One of my clients had a problem with processing GPO on client computers. Different computers applied different settings from the same GPO...
Get Inactive Users Report for the past 60 days in a multi domain environment
I had a request recently to provide an inactive user report for the past 60 days. Basically, find out which accounts have...
Get Primary, Secondary, Tertiary DNS values and more from Multiple Servers
Came across a unique request to get primary, secondary, and tertiary DNS values for multiple computers/servers across the domain. I started writing...
Fix Active Directory broken security inheritance problem
Ran into a situation at a client location where in Active Directory, the security permissions applied to an OU were not getting...
How to Fix: Attribute userAccountControl of DC is: 0x82020
When running a DCDiag at a customer site today I had the following error occur: [su_box title=”” box_color=”#f3f1cb” title_color=”#000000″ radius=”6″]Warning: Attribute userAccountControl...