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?

2 Comments   [ - ] Hide Comments


  • Hi Kenrinc,

    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$"


    Sample 2

    Dim objComputer

    Set objComputer = GetObject("LDAP://CN=computername,DC=WINDOWS2000,DC=COM")
    objComputer.SetPassword "computername$"


    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
  • I also just found this:


    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
Please log in to comment

There are no answers at this time
Answer this question or Comment on this question for clarity