Home All Groups Group Topic Archive Search About

Moving of Computeraccounts



Author
10 May 2005 8:40 AM
MichaelL
Hi NG,

I would like to move a computer account from the generell "Computer" into,
for example, OU=Berlin and there in Clients.

I known how to move the account into the OU but not who to move it deeper.
Can anyone help me.

Regards

Michael Lechner

Author
10 May 2005 12:20 PM
Eng
Hi, try something like the script below.

Bye
Eng

Author: Eugenio Talarico
mailto: eugeniotalarico@REMOVE_MEvodafone.it
link:
http://cwashington.netreach.net/depo/view.asp?Index=968&ScriptType=vbscript

Description:
script to move a computer account from one OU to another

Script:

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
Author
10 May 2005 2:00 PM
MichaelL
Thanks, that helped!

Show quote
"Eng" wrote:

> Hi, try something like the script below.
>
> Bye
> Eng
>
> Author: Eugenio Talarico
> mailto: eugeniotalarico@REMOVE_MEvodafone.it
> link:
> http://cwashington.netreach.net/depo/view.asp?Index=968&ScriptType=vbscript
>
> Description:
> script to move a computer account from one OU to another
>
> Script:
>
> 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
>

AddThis Social Bookmark Button