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
Solved

Unlock and reset password at the same time

Posted on 2014-11-17
3
13 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
3 Comments
 
LVL 54

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Mapping Drives using Group policy preferences Are you still using old scripts to map your network drives if so this article will show you how to get away for old scripts and move toward Group Policy Preference for mapping them. First things f…
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

856 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