Solved

Unlock and reset password at the same time

Posted on 2014-11-17
3
15 Views
Last Modified: 2016-06-23
Hi Team,

Please help me developing a script (Powershell/ VBS/ command line) if i have to unlock and reset password at the same time for a handful of domain IDs

Distinguished name for the OU where i am having permission is mentioned below

OU=India,DC=XYZ,DC=com

Regards,
Gautam
0
Comment
Question by:Gautam Chaudhary
[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 Comments
 
LVL 55

Accepted Solution

by:
McKnife earned 250 total points
ID: 40447665
If you have a listfile (c:\temp\list.txt) with the corresponding usernames and you would like to give them a random password, just take:
for /f %%a in (c:\temp\list.txt) do net user %% /random /active
0
 
LVL 16

Assisted Solution

by:Joshua Grantom
Joshua Grantom earned 250 total points
ID: 40447873
Hey Gautum,

This will also set it where they have to change their password on next logon.

$newpwd = "NewPassword" -AsSecureString
$users = Get-Content C:\UserstoUnlock.txt | % { 
Unlock-ADAccount -Identity $_ -PassThru
Set-ADAccountPassword $_ -NewPassword $newpwd -Reset -PassThru | Set-ADuser -ChangePasswordAtLogon $True
}

Open in new window

0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

729 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