Login | |
|
 |
Joining machine to AD in specific OU - 4/20/2006 3:28:37 AM
|
|
 |
|
| |
awe3s
Posts: 21
Score: 0
Joined: 4/20/2006
Status: offline
|
I have the following script that joins a machine in AD in a specified OU. It calls a htm file located in a network share. User name and password is provided and then it puts machine into the domain. My question is: it runs but the machine doesn't go into the domain. Can someone please provide an input into where I'm going wrong? Thanks Dim strUser, strPassword, strDomain Const JOIN_DOMAIN = 1 Const ACCT_CREATE = 2 Const ACCT_DELETE = 4 Const WIN9X_UPGRADE = 16 Const DOMAIN_JOIN_IF_JOINED = 32 Const JOIN_UNSECURE = 64 Const MACHINE_PASSWORD_PASSED = 128 Const DEFERRED_SPN_SET = 256 Const INSTALL_INVOCATION = 262144 ' Declare domain and the OU strDomain = "MYDOMAIN.DOMAIN.COM" strOU = "OU=Computers,OU=OUNAME,OU=OUNAME,DC=MYDOMAIN,DC=DOMAIN,DC=com" ' Disconnect drive Z if mapped and then re mapped it Set objNetwork = CreateObject("WScript.Network") On Error Resume Next objNetwork.RemoveNetworkDrive "Z:" On Error Goto 0 objNetwork.MapNetworkDrive "Z:", "\\SERVERNAME\SHARE", , "USERNAME", "PASSWORD" ' Call the HTML file to input username and password On Error Resume Next Set objExplorer = WScript.CreateObject _ ("InternetExplorer.Application", "IE_") objExplorer.Navigate "\\SERVERNAME\SHARE\password.htm" objExplorer.ToolBar = 0 objExplorer.StatusBar = 0 objExplorer.Width = 400 objExplorer.Height = 490 objExplorer.Left = 300 objExplorer.Top = 200 objExplorer.Visible = 1 Do While (objExplorer.Document.Body.All.OKClicked.Value = "") Wscript.Sleep 250 Loop strUser = objExplorer.Document.Body.All.UserName.value strPassword = objExplorer.Document.Body.All.UserPassword.Value strButton = objExplorer.Document.Body.All.OKClicked.Value objExplorer.Quit Wscript.Sleep 250 If strButton = "Cancelled" Then Wscript.Quit Else ' Join machine to the domain on the specified OU strComputer = objNetwork.ComputerName Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _ strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _ strComputer & "'") ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _ strPassword, strDomain & "\" & strUser, strOU, _ JOIN_DOMAIN + ACCT_CREATE) END If ' Reboot machine Set WshShell=WScript.CreateObject("WScript.Shell") nREBOOT=wshShell.Run("shutdown -r -t 00",0,TRUE)
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|