Unlocking bulk AD user accounts through Script

Gautam Chaudhary
Gautam Chaudhary used Ask the Experts™
on
Please help me developing a script (Powershell/ VBS/ command line) for unlocking bulk AD user accounts . Script will be fetching the list of IDs from a .txt / .xls file

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

OU=India,DC=XYZ,DC=com
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Specialist Consultant
Top Expert 2014
Commented:
No need for a text file, the below will simply identify accounts within an OU that are locked out and then unlock the account for you.
Import-Module ActiveDirectory
Search-ADAccount –SearchBase ‘OU=India,DC=XYZ,DC=com’ –LockedOut | Unlock-ADAccount

Open in new window

Gautam ChaudharyExecutive

Author

Commented:
It is a PS script...right but what do i do if i need to see the output for the query that what all are the accounts that has been unlocked
Joshua GrantomSenior Systems Administrator
Top Expert 2014

Commented:
Add -Passthru

Import-Module ActiveDirectory
Search-ADAccount –SearchBase ‘OU=India,DC=XYZ,DC=com’ –LockedOut | Unlock-ADAccount -Passthru

Open in new window

OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Gautam ChaudharyExecutive

Author

Commented:
Thanks VB ITS.... this solves half of my purpose....Please help if i have to unlock and reset password at the same time for a handful of domain IDs.
Gautam ChaudharyExecutive

Author

Commented:
Thanks Joshua Grantom.
Can you please help if i have to unlock and reset password at the same time for a handful of domain IDs provided the list of IDs will be fetched from a file kept at a location
Joshua GrantomSenior Systems Administrator
Top Expert 2014

Commented:
Gautam,

Yes I can help you, please post a new question as you have selected an answer for this one already.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial