Question : VBScript to move a computer account

I want to move a single Active Directory computer account from one OU to another on a workstation that is not in the domain.  I need a script that will authenticate to the domain and move one specific computer account to another OU.  For example:

Move myComputer account from
ou=Computers,dc=myDomain,dc=com
To
ou=accounting_computers,ou=xyz_computers,dc=myDomain,dc=com

Any suggestions on how I can do this?

Answer : VBScript to move a computer account

OK, I have tested it....we need to specify a specific domain controller to connect to, so in strNewOUPath, add the domain controller name, and it should work.

Regards,

Rob.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Const ADS_SECURE_AUTHENTICATION = &H1
Const ADS_USE_ENCRYPTION = &H2
Const ADS_SERVER_BIND = &H200
strNewOUPath = "LDAP://dcserver.domain.com/OU=Computers,OU=MainSite,OU=Sites,dc=domain,dc=com"
strComputerPath = "LDAP://CN=ComputerNameToMove,ou=IT Computers,OU=MainSite,OU=Sites,dc=domain,dc=com"
strUser = "domain\administrator"
strPassword = InputBox("Enter password:")

Set objDSO = GetObject("LDAP:")
Set objNewOU = objDSO.OpenDSObject(strNewOUPath, strUser, strPassword, ADS_SECURE_AUTHENTICATION + ADS_SERVER_BIND)
On Error Resume Next
objNewOU.MoveHere strComputerPath, vbNullString
If Err.Number = 0 Then
	MsgBox "Computer moved successfully."
Else
	MsgBox "Error " & Err.Number & ": " & Err.Description
End If
Random Solutions  
 
programming4us programming4us