Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion help needed moving mulitple computer accounts
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rob  
View profile  
 More options Jan 5 2007, 1:13 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Rob <R...@discussions.microsoft.com>
Date: Fri, 5 Jan 2007 05:13:01 -0800
Local: Fri, Jan 5 2007 1:13 pm
Subject: help needed moving mulitple computer accounts
Hi,
first off let me say I'm a total novice and am looking for a decent book -
any recommendations?  I'm considering the following:
1) AD Cookbook - Robbie ALlen
2) AD 3rd Ed - Joe Richards
3) AD - Robbie Allen/ Alistair Lowe-Norris
May not be the right newsgroup for this tho..

So, to my question...
I am trying to script moving multiple computer accounts from unknown OU's to
a  known OU within one domain in AD.
I have created a list of these computers that I want to move.  
I have found a script in the script centre:

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

objOU = GetObject("LDAP://ou=Redundant Objects,ou=Redundant Computer
Objects,dc=domain,dc=com")

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT ADsPath FROM 'LDAP://dc=domain,dc=com' WHERE
objectCategory='computer' " & _
        "AND Name='computenamer'"
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    strADsPath = objRecordSet.Fields("ADsPath").Value
    objOU.MoveHere strADsPath, vbNullString
    objRecordSet.MoveNext
Loop

>>finish

http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun06/h...
(I've changed computername and domainname)
Now this is supposed to move a comp account from an unknown OU to known OU
however I tested this with one computer account and it didn't work.

I then found this post which details writing a batch file and using an input
file:

1 input.txt

computer_name_1
computer:name_2

2 the batch file

@echo off

echo ****************************************
Echo * script to move computers*
echo ****************************************

for /F %%1 in (input.txt) do (
cscript move_cmp.vbs %%1 //B //Nologo >> err_log.txt 2>>&1 )

3 the VBS move_cmp.vbs FILE

dim nomepc
ParseCommandLine()

Const ADS_PROPERTY_APPEND = 3
Set objRootDSE = GetObject("LDAP://rootDSE")

'************************************************************************** ***
'* INTO STRVARIABL LINE PUT THE PATH WHERE THE object will be moved
'* (EX: strVariabl = ",OU=Standard Users,OU=DomainNAME,")
'************************************************************************** ***
'************************************************************************** ***
strVariabl = "OU=Public Desktops,OU=PIPPO,OU=PIPPO"
'************************************************************************** ***
'************************************************************************** ***
'************************************************************************** ***
strFissa = strVariabl & "," & objRootDSE.Get("defaultNamingContext")
wscript.echo strFissa

Set objNewOU = GetObject("LDAP://"& strFissa)
Set objMoveComputer = objNewOU.MoveHere _
("LDAP://CN="& nomepc & ",CN=Computers," &
objRootDSE.Get("defaultNamingContext"), "CN=" &nomepc)

Sub ParseCommandLine()
Dim vArgs

set vArgs = WScript.Arguments

if vArgs.Count <> 1 then
DisplayUsage()
Else
nomepc = vArgs(0)
End if
End Sub

I've not changed any of the variables here but this script only looks in the
computers container and not throught the entire AD structure.
Ideally I would like either the first script to use a lookup file or the 2nd
script to search the entire AD but my knowledge does not extend that far.
I'd be very grateful for any help.
Thanks


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google