Solved

How to automatically uncheck Password Never Expires for all user in an OU?

Posted on 2004-08-24
4
539 Views
Last Modified: 2008-03-10
Hello Experts!  I'm looking for a way to AUTOMATICALY uncheck the "Password Never Expires" option on user account properties for all users under an OU.  What would be the easiest way to do this?
0
Comment
Question by:mb2010
  • 2
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
Debsyl99 earned 250 total points
Comment Utility
Hi
You could use a vb script - Try paste the following into a text file, add your relevant ou and dc and rename the file to yourfile.vbs ensuring a .vbs extension and a name you'll recognise, then test the script on a test ou prior to applying it,

Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Set OU = GetObject("LDAP://OU=yourou, DC=yourdomain,DC=com")
'Gather each username.
For Each oUser In OU
'Make sure they are only USER class.
If oUser.Class = "user" Then
intUAC = oUser.Get("userAccountControl")
If ADS_UF_DONT_EXPIRE_PASSWD AND intUAC Then
oUser.Put "userAccountControl", intUAC XOR _
ADS_UF_DONT_EXPIRE_PASSWD
oUser.SetInfo
End If
End If
Next
Wscript.echo "All password expiry settings for the ou are unchecked"
Wscript.Quit

Deb :))
0
 

Author Comment

by:mb2010
Comment Utility
Works perfect!  I LOVE IT!

Thanks much!!
0
 
LVL 20

Expert Comment

by:Debsyl99
Comment Utility
Thanks - glad to help!

Deb :))
0
 

Author Comment

by:mb2010
Comment Utility
Forgot to ask.  Will this script work on the sub OUs also?  If not, I need it to do so.  Thanks much!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you ever set up your wireless router at home or in the office to find that you little pop-up bubble in the bottom right-hand corner of Windows read "IP Conflict - One of more computers on the network have been assigned the following IP address"…
This is the first one of a series of articles I’ll be writing to address technical issues that are always referred to as network problems. The network boundaries have changed, therefore having an understanding of how each piece in the network  puzzl…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

15 Experts available now in Live!

Get 1:1 Help Now