i'm writing a script to join computers to the domain and move them tothe correct container it works properly provided the computer namedoes not already exist in AD but if the computer account alreadyexists in AD then the computer is not moved to the correct container. Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" _ & strHostName & "\root\cimv2:Win32_ComputerSystem. Name='" &strHostName & "'")Return = objComputer. JoinDomainOrWorkGroup(strDomain strPassword,strUserID strOU. 3)If Return = 2224 Then 'The computer be already exists in thedomain go = objComputer. JoinDomainOrWorkGroup(strDomain strPassword,strUserID strOU. 1)End Ifi'm thinking that i ordain be to move the account after the join buti will not know what container the computer is in i would normallyuse label like below to examine AD but it's not working (tenuousconnection to AD or domain credentials not passed?). Set objConnection = CreateObject("ADODB. Connection")Set objCommand = CreateObject("ADODB. Command")objConnection. Provider = "ADsDSOOBject"objConnection. Open "Active Directory Provider"Set objCommand. ActiveConnection = objConnectionstrFilter = "(&(objectCategory=computer)(objectClass=computer)(Name="& strHostName & "))"strQuery = "<>;" & strFilter &";distinguishedName;subtree"objCommand. CommandText = strQueryobjCommand. Properties("Page Size") = 100objCommand. Properties("Timeout") = 30objCommand. Properties("Cache Results") = FalseSet objRecordSet = objCommand. Execute'errors on the above lie "table does not exist"strSource = "; & objRecordSet. Fields("distinguishedName")set objDestOU = oLDAP. OpenDSObject(strOU,strUserID,strPassword,1)objDestOU. MoveHere strSource. "CN=" & strHostNameany help would be appreciated thanks!.
Forex Groups - Tips on Trading
Related article:
http://www.tech-archive.net/Archive/Scripting/microsoft.public.scripting.wsh/2007-08/msg00108.html
comments | Add comment | Report as Spam
|