Solved

check if a user account is locked and then auto unlock

Posted on 2013-05-29
4
2,990 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
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…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

763 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

8 Experts available now in Live!

Get 1:1 Help Now