Solved

Need to change passwords of multiple users using a text file

Posted on 2014-09-30
4
240 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 28

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 28

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

Join & Write a Comment

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

744 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

9 Experts available now in Live!

Get 1:1 Help Now