Checking machine account before adding to domain
I'm using the classic "joindomain.vbs" script which works fine. I'd like to move to something that checks for the machine name in AD first, if it's found, do a machine account reset and if not found just continue and add. Anyone come up with one of these?
Ken-
Ken-
2 Comments
[ + ] Show comments
Answers (0)
Please log in to answer
Be the first to answer this question
I would also like to know this.
I did discover the following from https://support.microsoft.com/en-us/help/216393/resetting-computer-accounts-in-windows
Microsoft Visual Basic script
You can use a script to reset the machine account. You need to connect to the computer account using the IADsUser interface. You can then use the SetPassword method to set the password to an initial value. The initial password of a computer is always "computername$".
The following sample scripts may not work in all environments and should be tested before implementation. The first example is for Windows NT 4.0 computer accounts and the second is for Windows 2000 or Windows XP computer accounts.
Sample 1
Dim objComputer
Set objComputer = GetObject("WinNT://WINDOWS2000/computername$")
objComputer.SetPassword "computername$"
Wscript.Quit
Sample 2
Dim objComputer
Set objComputer = GetObject("LDAP://CN=computername,DC=WINDOWS2000,DC=COM")
objComputer.SetPassword "computername$"
Wscript.Quit
For more information about how to determine whether the date and the time of event 5722 match the decoded date and time, click the following article numbers to view the articles in the Microsoft Knowledge Base:
175024 Resetting Domain Member Secure Channel - jboling 7 years ago
https://technet.microsoft.com/en-us/library/cc753596(v=ws.11).aspx#BKMK_cmd
To reset a computer account using a command line
To open a command prompt, click Start , click Run , type cmd , and then click OK .
To open a command prompt in Windows Server 2012, click Start , type cmd , and then click OK .
Type the following command, and then press ENTER:
dsmod computer <ComputerDN> -reset - jboling 7 years ago