Solved

Need to change passwords of multiple users using a text file

Posted on 2014-09-30
4
246 Views
Last Modified: 2014-10-16
I have about a 100 users that I need to reset their passwords. I can set them to the same password.

How can I do this using a list of users in text file?

I found some script, but nothing really tells what needs to be change and how to do it.

thanks
0
Comment
Question by:rdefino
  • 2
4 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 40353750
If you have PowerShell AD tools you can use this:

gc userlist.txt | % {
Set-ADAccountPassword -identity $_-Reset -NewPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force)
}

Open in new window



http://technet.microsoft.com/en-us/library/ee617261.aspx
0
 

Author Comment

by:rdefino
ID: 40353756
Where is the syntax do I enter the password that I want to change to?
0
 
LVL 29

Accepted Solution

by:
becraig earned 500 total points
ID: 40353761
import-module ac*
gc userlist.txt | % {
Set-ADAccountPassword -identity $_-Reset -NewPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force)
}
          

Open in new window

                               

This line imports the active directory module
Import-module ac*

Then we pipe it into a foreach
| % {}

Then to break down the command:
We call Set-AdAccountPassword
Then we specify the user sam account or DN etc
-identity $_ (The $_ represents the value from the text file as a part of the foreach loop)

We then use the reset flag to call a reset without inputting the old password
-reset

Then we set the new password - using conveert-to-securestring so powershell knows it is a valid password.
The password is the value as a part of the plaintext flag
-Asplaintext "password value"

Then we use force to complete this
-Force
0
 
LVL 53

Expert Comment

by:McKnife
ID: 40356135
Alternatively, the most simple batch code:
for /f %%a in (c:\temp\userlist.txt) do net user %%a newpassword /domain

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now