Solved

check if a user account is locked and then auto unlock

Posted on 2013-05-29
4
3,178 Views
Last Modified: 2013-06-14
Hi all,
We currently run a batch file each morning to check if important domain monitoring accounts are locked, there are 4 accounts. Batch example is:

net user user1 /domain | FIND /I "account active"
net user user2 /domain | FIND /I "account active"
net user user3 /domain | FIND /I "account active"
net user  user4 /domain | FIND /I "account active"

If any of the accounts are locked we trpe in from the command lind: c:\>user1.bat
User1.bat is simply: Net user user1 /DOMAIN /active:YES

I was wondering whether there was a way of combining the two where-by if on teh first batch file an account is locked it will unlock it, if you know what i mean?

Thanks as always.
0
Comment
Question by:Jason Thomas
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
Jaroslav Mraz earned 500 total points
ID: 39203863
You can simple use only NET USER1 /DOMAIN /active:YES script it doesn't meter if it is active or not. Or do you log it somewhere?

NET USER1 /DOMAIN /active:YES
NET USER2 /DOMAIN /active:YES
NET USER3 /DOMAIN /active:YES
NET USER4 /DOMAIN /active:YES
0
 
LVL 1

Author Comment

by:Jason Thomas
ID: 39203992
Cool mate, nope we don't log it so if teh account is active and we run that command it sees it as active and does nothing?
0
 
LVL 15

Expert Comment

by:Jaroslav Mraz
ID: 39204085
Yop,

it maybe write you back error that acount is alredy activated :) but nothing else cause this switch only setting this one parameter to YES.


http://support.microsoft.com/kb/251394
0
 
LVL 1

Author Closing Comment

by:Jason Thomas
ID: 39247148
Thanks
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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…

756 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