Jump to content

Trouble with script that joins to the domain


Recommended Posts

I am modifying a script that I found on a support form online a while back. It seems to work pretty well. However, when I input my username and password in the script, when running, the computer is unable to join to the domain because it claims the username or password I entered is bad. I am certain it is correct. Here is the code:

 

#RequireAdmin
$ComputerName = InputBox("Computer Name Required", "Please enter the Computer Name", "")

ShellExecute("sysdm.cpl")

WinWait("System Properties")
WinActivate("System Properties","To use a wizard to join a domain or workgroup")

Send("!C")

WinWait("Computer Name/Domain Changes", "You can change the name and")
WinActivate("Computer Name/Domain Changes", "You can change the name and")
Send("!C")
Send($ComputerName)
Send("!D")
Send("{TAB}")
Send("mydomain.pvt")
Send("{ENTER}")

WinWait("Windows Security", "OK")
WinActivate("Windows Security", "OK")
Send("mydomain\username")
Send("{TAB}")
Send("password")
Send("{TAB}")
Send("{ENTER}")

WinWait("Computer Name/Domain Changes", "Welcome to the mydomain.pvt domain.")
WinActivate("Computer Name/Domain Changes", "Welcome to the mydomain.pvt domain.")
Send("{ENTER}")

Sleep(15000)
if WinExists("Computer Name/Domain Changes", "OK") Then
    Send("{ENTER}")
EndIf

WinWait("System Properties", "To use a wizard")
WinActivate("System Properties","To use a wizard")
Send("{ENTER}")

WinWait("Microsoft Windows", "&Restart Now")
WinActivate("Microsoft Windows", "&Restart Now")
Send("!R")
 

Any ideas? The username and password is certainly correct. Is there a Windows security feature that is able to detect that you are running an automation script?

Edited by jshapy8
Link to comment
Share on other sites

  • Moderators

Hi, jshapy8, welcome to the forum. Take a look at the A.D. functions in the help file, especially _AD_JoinDomain. It will make your life much easier ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hi, jshapy8, welcome to the forum. Take a look at the A.D. functions in the help file, especially _AD_JoinDomain. It will make your life much easier ;)

​I actually have looked at that one in the past. I would just like to simply automate the task that I would usually complete to join to the domain. Also I am frankly just generally interested in why my credentials don't work using this script. It should work, shouldn't it?

Link to comment
Share on other sites

  • Moderators

"Should" is a relative term. I have a number of scripts for domain work, and run them all in the context of my domain admin account, and yes, they all work. But you are doing a lot of send in your script, and have no real error checking (hard to do when you're just sending keystrokes), so beyond saying "Yes, it should work", it is difficult to point you to a potential cause for failure.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

​I figured out the issue. The problem was at there was an exclamation point in my password. I had to write a separate send command for the exclamation point rather than just including it in one string with the rest of the password. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...