Sleeper Veteran Posted November 29, 2004 Veteran Share Posted November 29, 2004 Im wanting to create a batch file that will create local user accounts for all our Systems Admin team on a server. I know that I can use "net user" but this does not let you specify that you want the user to change the password at next logon. I've getting a hold of addusers.exe but this does not seem to be compatibale with Windows Server 2003. Has anyone got any other ideas? Regards. Link to comment https://www.neowin.net/forum/topic/250496-create-accounts-from-command-line/ Share on other sites More sharing options...
Joel Posted November 29, 2004 Share Posted November 29, 2004 PwdLastSet.vbs ' PwdLastSet.vbs ' VBScript to FORCE a user's password change ' Author Ulrich P amended by Guy Thomas ' Version 2.0 - October 17th 2004 ' --------------------------------------------------------------' Option Explicit Dim objOU, objUser, objRootDSE Dim strContainer, strLastUser, strDNSDomain, strPassword Dim intCounter, intAccValue, intPwdValue Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("DefaultNamingContext") intAccValue = 544 intPwdValue = 0 ' -------------------------------------------------------------' ' Important change OU= to reflect your domain ' -------------------------------------------------------------' strContainer = "OU=Accounts, " strPassword = "P@ssw0rd" ' -------------------------------------------------------------' ' Makes the user change P@ssw0rd at first logon ' -------------------------------------------------------------' strContainer = strContainer & strDNSDomain set objOU =GetObject("LDAP://" & strContainer ) intCounter = 0 For each objUser in objOU If objUser.class="user" then objUser.SetPassword strPassword objUser.SetInfo objUser.Put "pwdLastSet", intPwdValue objUser.SetInfo objUser.Put "userAccountControl", intAccValue objUser.SetInfo intCounter = intCounter +1 strLastUser = objUser.Get ("name") End if next WScript.Echo strPassword & " is Password. UserAccountValue = " _ & intAccValue WScript.Quit ' End of Script http://www.computerperformance.co.uk/ezine/ezine50.htm Link to comment https://www.neowin.net/forum/topic/250496-create-accounts-from-command-line/#findComment-585008611 Share on other sites More sharing options...
neo_joel Posted November 29, 2004 Share Posted November 29, 2004 hehe my friend actually tested a script like this at home and he set it to 5 million user accounts just to see if his box would handle it and it did :laugh: , can u imagine, 5 million user accounts hehe.. he is now going for 10 million. He told me this morning that his cpu usage has been at 100% for the past 12 hours creating those objects in AD, i found it quite humorous myself. :p Link to comment https://www.neowin.net/forum/topic/250496-create-accounts-from-command-line/#findComment-585008626 Share on other sites More sharing options...
Sleeper Veteran Posted November 29, 2004 Author Veteran Share Posted November 29, 2004 will this work for just local accounts on a 2003 Server as it is only in a workgroup Link to comment https://www.neowin.net/forum/topic/250496-create-accounts-from-command-line/#findComment-585008629 Share on other sites More sharing options...
Joel Posted November 29, 2004 Share Posted November 29, 2004 will this work for just local accounts on a 2003 Server as it is only in a workgroup 585008629[/snapback] See now, you never mentioned that. :p I doubt it. Link to comment https://www.neowin.net/forum/topic/250496-create-accounts-from-command-line/#findComment-585010567 Share on other sites More sharing options...
Aaron P Posted November 30, 2004 Share Posted November 30, 2004 Try this (I've not tested, but it should work). Save as a .VBS file. strComputer = "." Set colAccounts = GetObject("WinNT://" & strComputer & "") colAccounts.Filter = Array("user") For Each objUser In colAccounts Set objUser = GetObject("WinNT:// " & strComputer & "/" & objUser.Name") objUser.Put "PasswordExpired", 1 objUser.SetInfo Next Link to comment https://www.neowin.net/forum/topic/250496-create-accounts-from-command-line/#findComment-585012636 Share on other sites More sharing options...
Sleeper Veteran Posted December 1, 2004 Author Veteran Share Posted December 1, 2004 Try this (I've not tested, but it should work). Save as a .VBS file. strComputer = "." Set colAccounts = GetObject("WinNT://" & strComputer & "") colAccounts.Filter = Array("user") For Each objUser In colAccounts ? ? Set objUser = GetObject("WinNT:// " & strComputer & "/" & objUser.Name") ? ? objUser.Put "PasswordExpired", 1 ? ? objUser.SetInfo Next 585012636[/snapback] didn't work f:( me :( Link to comment https://www.neowin.net/forum/topic/250496-create-accounts-from-command-line/#findComment-585021243 Share on other sites More sharing options...
Aaron P Posted December 1, 2004 Share Posted December 1, 2004 What error do you get? Link to comment https://www.neowin.net/forum/topic/250496-create-accounts-from-command-line/#findComment-585024647 Share on other sites More sharing options...
Sleeper Veteran Posted December 2, 2004 Author Veteran Share Posted December 2, 2004 got it working :D thanks very much. Would it be possible to single it down to a list of users, rather than them all? Link to comment https://www.neowin.net/forum/topic/250496-create-accounts-from-command-line/#findComment-585027171 Share on other sites More sharing options...
Aaron P Posted December 2, 2004 Share Posted December 2, 2004 with a few changes you could read the list of users from a text file, or specify the username on the command line Link to comment https://www.neowin.net/forum/topic/250496-create-accounts-from-command-line/#findComment-585028209 Share on other sites More sharing options...
OliverPlattner Posted December 22, 2004 Share Posted December 22, 2004 with a few changes you could read the list of users from a text file, or specify the username on the command line 585028209[/snapback] I tried using this script on my XP machine and it would answer: Line:7 Char:77 unterminated string constant Anyone know why? Link to comment https://www.neowin.net/forum/topic/250496-create-accounts-from-command-line/#findComment-585143672 Share on other sites More sharing options...
Recommended Posts