Use this:
This script is composed by 3 file
1 input.txt the input file is used to retrieve the object name
2 the batch used to "run" the vbs and take the information from the txt
3 the VBS file move_cmp.vbs
The file BAT move a computer from CN=COMPUTERS
to ANOTHER ONE that you have to specify into the VBS
file.
That's all.
Script by: Eugenio Talarico
mailto: eugeniot @ _R_E_M_O_V_E___ larico.it
so here the structure:
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
>> Stay informed about: Move multiple computer accounts in a txt file from one OU ..