Solved

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

Posted on 2011-02-11
5
419 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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