Solved

Unlock and reset password at the same time

Posted on 2014-11-17
3
9 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 53

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I'm sure that every Windows systems administrator has written, or at least used, a batch or VBS login script at some point in their career, whether it is to map network drives, install printers, or set some user preferences.  No more! With Window…
I know all systems administrator at some time or another has had to create a script to copy file from a server share to a desktop. Well now there is an easy way to do this in Group Policy. Using Group policy preferences is not hard. The first thing …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

758 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

17 Experts available now in Live!

Get 1:1 Help Now