Solved

How do I include many user names to my Powershell script to reset Passwords?

Posted on 2011-02-11
5
412 Views
Last Modified: 2012-05-11
Experts,

       How do I add more users to my script to update their password?

Thanks, Missymadi
$users = get-qaduser -samaccountname USERNAME 
$users | %{
set-qaduser -Userpassword 'Test'
get-qaduser -samaccountname $_.samaccountname | Select samaccountname, passwordlastset | out-file c:\PwdChanged.txt -noclobber
}

Open in new window

0
Comment
Question by:missymadi
  • 3
  • 2
5 Comments
 
LVL 27

Expert Comment

by:KenMcF
ID: 34873734
You can do it a few ways

$users = get-qaduser -searchbase "OU=Users_OU,DC=Domain,DC=Local"

$users = get-content c:\users.txt

$users = @(
"User1"
"User2"
"User3"
)
0
 

Author Comment

by:missymadi
ID: 34874259
How would I add a line that notifies the user that the script completed?
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34874365
The user running the script or the user that is having the password changed?
0
 

Author Comment

by:missymadi
ID: 34874466
The user running the script.
0
 
LVL 27

Accepted Solution

by:
KenMcF earned 500 total points
ID: 34874547
You can write it out to the console

$users | %{  
set-qaduser -Userpassword 'Test'  
Write-host "$($_) password was reset"
get-qaduser -samaccountname $_.samaccountname | Select samaccountname, passwordlastset | out-file c:\PwdChanged.txt -noclobber  
}
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Why would I want to create a function for tracking messages? I am glad you asked. As with most monotonous/routine tasks, human error tends to creep in after doing the same task over and over again. By creating a function, you load the function once…
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

18 Experts available now in Live!

Get 1:1 Help Now