title: Change password expiration date in Active Directory using VBS
body: <p>I'm trying to change the password expiration date for a user in Active Directory using VBScript.  I have the code to obtain information about a user's password, but I can't find anything about how to change it.  Any help would be greatly appreciated! </p>
  
  <p>Here's my code:</p>
  
  <pre><code>Const SEC_IN_DAY = 86400
  Const ADS_UF_DONT_EXPIRE_PASSWD = &amp;h10000
  
  Set objOU = GetObject("LDAP://CN=[username],OU=Users,OU=New York,OU=NA,OU=[domain],DC=[domain],DC=firm")
  
  intCurrentValue = objOU.Get("userAccountControl")
  
  If intCurrentValue and ADS_UF_DONT_EXPIRE_PASSWD Then
    wscript.echo "The password does not expire."
  Else
    dtmValue = objOU.PasswordLastChanged 
    Wscript.echo "The password was last changed on " &amp; _
    DateValue(dtmValue) &amp; " at " &amp; TimeValue(dtmValue) &amp; VbCrLf &amp; _
    "The difference between when the password was last set" &amp; VbCrLf &amp; _
    "and today is " &amp; int(now - dtmValue) &amp; " days"
    intTimeInterval = int(now - dtmValue)
  
    Set objDomainNT = GetObject("WinNT://ropesgray")
    intMaxPwdAge = objDomainNT.Get("MaxPasswordAge")
    If intMaxPwdAge &lt; 0 Then
      WScript.Echo "The Maximum Password Age is set to 0 in the " &amp; _
        "domain. Therefore, the password does not expire."
    Else
      intMaxPwdAge = (intMaxPwdAge/SEC_IN_DAY)
      Wscript.echo "The maximum password age is " &amp; intMaxPwdAge &amp; " days"
      If intTimeInterval &gt;= intMaxPwdAge Then
        Wscript.echo "The password has expired."
      Else
        Wscript.echo "The password will expire on " &amp; _
        DateValue(dtmValue + intMaxPwdAge) &amp; " (" &amp; _
        int((dtmValue + intMaxPwdAge) - now) &amp; " days from today" &amp; ")."
      End If
    End If
  End If
  
  
  'strUserPrincipalName = objOU.Get("userPrincipalName")
  'strSAMAccountName = objOU.Get("sAMAccountName")
  'strMaxPWAge = objOU.Get("manager")
  
  'WScript.Echo strUserPrincipalName
  'WScript.Echo strSAMAccountName
  'WScript.Echo strMaxPWAge
  </code></pre>