Solved

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

Posted on 2011-02-11
5
417 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Utilizing an array to gracefully append to a list of EmailAddresses
A brief introduction to what I consider to be the best editor for PowerShell.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

733 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