Script let user in AD 2003 change password expire date to next 2 week

Posted on 2011-10-10
Last Modified: 2012-05-12
Hi All,

      Any one know how to set all user password expire date to next 2 weeks from today.

      From internet I can find how to view password will be expire but I can't find how to let system force change password next week or next 2 week.

Thank in advance.
Question by:Simpson_STL
    LVL 20

    Expert Comment

    by:Hendrik Wiese
    You would have to create a GPO for this. Please see links below on how to setup the Password policy using GPO.

    You would need to read from "For a domain, and you are on a member server or a workstation that is joined to the domain"

    Please go to for instructions?

    Author Comment

    Thank you for your comment,

     I'm already set policy to change password each 180 days, but as of today new policy release to let every one to change password with in this month, So I'm would like to change their password expiredate to next 2 weeks. Please advise.

    LVL 20

    Expert Comment

    by:Hendrik Wiese
    You can change it to 14days and enforce the policy. Then after they restart their machines and everyone has changed their password then you can just set it back to 180 days if you want.
    LVL 20

    Accepted Solution

    You can also use the following tool to force a password change in bulk:
    LVL 9

    Assisted Solution

    Hi Please find the code to set password expiration date.

    There are two ways to approach this problem:

    1. Set a New Expiration Date
    2.  Expire the password so it must be change at next logon.

    Option Explicit 
    On Error Resume Next 
    Dim oQuery 
    Dim objConnection 
    Dim objCommand 
    Dim objRecordSet 
    Dim objUser 
    Dim objRoot 
    Dim NamingContext 
    set objRoot = getobject("LDAP://RootDSE") 
    NamingContext = objRoot.get("defaultNamingContext") 
    oQuery = "<LDAP://" & NamingContext & ">;" & "(objectClass=user);adspath;subtree" 
    '=======all the following lines are the same for every script==================== 
    Set objConnection = CreateObject("ADODB.Connection") 
    Set objCommand = CreateObject("ADODB.Command") 
    objConnection.Open "Provider=ADsDSOObject;" 
    objCommand.ActiveConnection = objConnection 
    objCommand.CommandText = oQuery 
    Set objRecordSet = objCommand.Execute 
    While Not objRecordSet.EOF 
    Set objUser=GetObject(objRecordSet(0)) 
    'Set a New Expiration Date
     objUser.AccountExpirationDate = #30/11/2011#
    ' Expire the password so it must be change at next logon.
    objUser.pwdLastSet = 0
    Set objUser=Nothing 

    Open in new window

    Hope this helps!

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (…
    This script will sweep a range of IP addresses (class c only, and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    729 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

    22 Experts available now in Live!

    Get 1:1 Help Now