Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I disable "User must change password at next logon" from command line?

Posted on 2005-04-15
6
Medium Priority
?
6,177 Views
Last Modified: 2013-12-04
How do I disable "User must change password at next logon" from command line?

I want to disable this flag and enable "Password never expires" on all of my local Windows 2000 user accounts (this computer is not part of an Active Directory domain, the accounts are local). Can you please provide me with a VbScript or a set of command line commands so I can do this as a batch file?

Thanks!!
0
Comment
Question by:pmosinskis
  • 2
4 Comments
 
LVL 71

Expert Comment

by:Chris Dent
ID: 13795819
Hi,

This works in part, but because pwdLastSet is an AD specific property setting it at the moment doesn't work. Still I'll look into it in the morning, you can have this for now at least (VBScript):


Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set colAccounts = GetObject("WinNT://" & strComputer & "")

colAccounts.Filter = Array("user")

For Each objUser in colAccounts
    arrFlags = objUser.Get("UserFlags")

    ' Disable Change at Next Logon

    ' objUser.Put "pwdLastSet", 1
    ' objUser.SetInfo

    ' Enable Password Never Expires

    If (arrFlags And ADS_UF_DONT_EXPIRE_PASSWD) <> 0 Then
        objUser.Put "UserFlags", arrFlags XOr ADS_UF_DONT_EXPIRE_PASSWD
        objUser.SetInfo
    End If
Next


Regards,

Chris
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 500 total points
ID: 13797092

All fixed. Let me know if it doesn't work.


Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set colAccounts = GetObject("WinNT://" & strComputer)

colAccounts.Filter = Array("user")

For Each objUser in colAccounts
      arrFlags = objUser.Get("UserFlags")

      ' Disable Change at Next Logon

      objUser.PasswordExpired = 0
      objUser.SetInfo

      ' Enable Password Never Expires

      objUser.Put "UserFlags", arrFlags XOr ADS_UF_DONT_EXPIRE_PASSWD
      objUser.SetInfo
Next
0
 

Expert Comment

by:Herve CHEVALIER
ID: 22568191
Solution :

Set usr = GetObject("LDAP://CN=user, OU=Accounts, DC=domainname, DC=Com")
usr.Put "pwdLastSet", CLng(-1)
usr.SetInfo

Done on thousands account AD Windows 2003 today.
0
 

Expert Comment

by:cbeene1872
ID: 35085876
Thanks for this info!  Helped me a BUNCH!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Security measures require Windows be logged in using Standard User login (not Administrator).  Yet, sometimes an application has to be run “As Administrator” from a Standard User login.  This paper describes how to create a shortcut icon to launch a…
Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

810 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