Welcome to ServerForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Move Computer from default OU to another during build proc..

 
   Windows Server (Home) -> Windows Server Scripting RSS
Next:  Disabling Local user accounts from member servers..  
Author Message
RC

External


Since: Jun 29, 2006
Posts: 5



(Msg. 1) Posted: Thu Jun 29, 2006 8:06 am
Post subject: Move Computer from default OU to another during build process
Archived from groups: microsoft>public>windows>server>scripting (more info?)

I am attempting to automate the move of a computer account from the default
container to an OU I specify either during the imaging/sysprep process or on
first logon. I'm currently experimenting with the sample script shown below
but it requires that a specific computer name be provided. I need a process
that will actually use the name of the workstation that the script is running
on since this will go into our corporate build. This process will need to run
on Windows XP SP2 workstations in a Windows 2000 Active Directory domain
structure.

Sample Script from MS Script Repository:

Set objNewOU = GetObject("LDAP://OU=Finance,DC=fabrikam,DC=com")

Set objMoveComputer = objNewOU.MoveHere _
("LDAP://CN=atl-pro-03,CN=Computers,DC=fabrikam,DC=com", "CN=atl-pro-03")

Any suggestions about other methods to accomplish this would be helpful.
Regards,

 >> Stay informed about: Move Computer from default OU to another during build proc.. 
Back to top
Login to vote
Richard Mueller

External


Since: Jun 03, 2006
Posts: 31



(Msg. 2) Posted: Thu Jun 29, 2006 10:55 am
Post subject: Re: Move Computer from default OU to another during build process [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

RC wrote:

>I am attempting to automate the move of a computer account from the default
> container to an OU I specify either during the imaging/sysprep process or
> on
> first logon. I'm currently experimenting with the sample script shown
> below
> but it requires that a specific computer name be provided. I need a
> process
> that will actually use the name of the workstation that the script is
> running
> on since this will go into our corporate build. This process will need to
> run
> on Windows XP SP2 workstations in a Windows 2000 Active Directory domain
> structure.
>
> Sample Script from MS Script Repository:
>
> Set objNewOU = GetObject("LDAP://OU=Finance,DC=fabrikam,DC=com")
>
> Set objMoveComputer = objNewOU.MoveHere _
> ("LDAP://CN=atl-pro-03,CN=Computers,DC=fabrikam,DC=com",
> "CN=atl-pro-03")
>
> Any suggestions about other methods to accomplish this would be helpful.
> Regards,

If the client is W2k or above, you can use the ADSystemInfo object to
retrieve the distinguished name of the computer:

Set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName
Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN,
vbNullString)

I used vbNullString rather than the Relative Distinguished Name of the
object since we are moving and not renaming. Otherwise, you would need to
bind to the computer object to retrieve the Common Name.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

 >> Stay informed about: Move Computer from default OU to another during build proc.. 
Back to top
Login to vote
RC

External


Since: Jun 29, 2006
Posts: 5



(Msg. 3) Posted: Thu Jun 29, 2006 10:55 am
Post subject: Re: Move Computer from default OU to another during build process [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Richard Mueller" wrote:

> RC wrote:
>
> >I am attempting to automate the move of a computer account from the default
> > container to an OU I specify either during the imaging/sysprep process or
> > on
> > first logon. I'm currently experimenting with the sample script shown
> > below
> > but it requires that a specific computer name be provided. I need a
> > process
> > that will actually use the name of the workstation that the script is
> > running
> > on since this will go into our corporate build. This process will need to
> > run
> > on Windows XP SP2 workstations in a Windows 2000 Active Directory domain
> > structure.
> >
> > Sample Script from MS Script Repository:
> >
> > Set objNewOU = GetObject("LDAP://OU=Finance,DC=fabrikam,DC=com")
> >
> > Set objMoveComputer = objNewOU.MoveHere _
> > ("LDAP://CN=atl-pro-03,CN=Computers,DC=fabrikam,DC=com",
> > "CN=atl-pro-03")
> >
> > Any suggestions about other methods to accomplish this would be helpful.
> > Regards,
>
> If the client is W2k or above, you can use the ADSystemInfo object to
> retrieve the distinguished name of the computer:
>
> Set objSysInfo = CreateObject("ADSystemInfo")
> strComputerDN = objSysInfo.ComputerName
> Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN,
> vbNullString)
>
> I used vbNullString rather than the Relative Distinguished Name of the
> object since we are moving and not renaming. Otherwise, you would need to
> bind to the computer object to retrieve the Common Name.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>
>
>
Richard,

Thank you for the reply. Unfortunatly I'm fairly new to these scripting
methods and don't know how to incorporate the desired destination OU with
your example.
 >> Stay informed about: Move Computer from default OU to another during build proc.. 
Back to top
Login to vote
Richard Mueller

External


Since: Jun 03, 2006
Posts: 31



(Msg. 4) Posted: Thu Jun 29, 2006 7:04 pm
Post subject: Re: Move Computer from default OU to another during build process [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>>
> Richard,
>
> Thank you for the reply. Unfortunatly I'm fairly new to these scripting
> methods and don't know how to incorporate the desired destination OU with
> your example.

Hi,

I tested the script below (with a different target OU) and it moved the
computer the script was run on into the target OU. Watch for line wrapping:
====================
Option Explicit
Dim objNewOU, objSysInfo, strComputerDN, objMoveComputer

' Bind to target OU, where computer object will be moved.
Set objNewOU = GetObject("LDAP://OU=Sales,dc=MyDomain,dc=com")

' Determine Distinguished Name of local computer.
Set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName

' Move this computer object to the target OU.
Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN,
vbNullString)

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
 >> Stay informed about: Move Computer from default OU to another during build proc.. 
Back to top
Login to vote
RC

External


Since: Jun 29, 2006
Posts: 5



(Msg. 5) Posted: Fri Jun 30, 2006 6:08 am
Post subject: Re: Move Computer from default OU to another during build process [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thank you Richard.

"Richard Mueller" wrote:

> >>
> > Richard,
> >
> > Thank you for the reply. Unfortunatly I'm fairly new to these scripting
> > methods and don't know how to incorporate the desired destination OU with
> > your example.
>
> Hi,
>
> I tested the script below (with a different target OU) and it moved the
> computer the script was run on into the target OU. Watch for line wrapping:
> ====================
> Option Explicit
> Dim objNewOU, objSysInfo, strComputerDN, objMoveComputer
>
> ' Bind to target OU, where computer object will be moved.
> Set objNewOU = GetObject("LDAP://OU=Sales,dc=MyDomain,dc=com")
>
> ' Determine Distinguished Name of local computer.
> Set objSysInfo = CreateObject("ADSystemInfo")
> strComputerDN = objSysInfo.ComputerName
>
> ' Move this computer object to the target OU.
> Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN,
> vbNullString)
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>
>
>
 >> Stay informed about: Move Computer from default OU to another during build proc.. 
Back to top
Login to vote
Jeffrey B

External


Since: Oct 26, 2006
Posts: 3



(Msg. 6) Posted: Thu Oct 26, 2006 10:36 am
Post subject: Re: Move Computer from default OU to another during build process [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hello guys I am also looking for script that moves Computer account to
another OU.
Ok,

Base on the script listed below. How would I start if Im moving a computer
account from the "computer container" to let say "SampleOU"

Thanks

"Richard Mueller" wrote:

> >>
> > Richard,
> >
> > Thank you for the reply. Unfortunatly I'm fairly new to these scripting
> > methods and don't know how to incorporate the desired destination OU with
> > your example.
>
> Hi,
>
> I tested the script below (with a different target OU) and it moved the
> computer the script was run on into the target OU. Watch for line wrapping:
> ====================
> Option Explicit
> Dim objNewOU, objSysInfo, strComputerDN, objMoveComputer
>
> ' Bind to target OU, where computer object will be moved.
> Set objNewOU = GetObject("LDAP://OU=Sales,dc=MyDomain,dc=com")
>
> ' Determine Distinguished Name of local computer.
> Set objSysInfo = CreateObject("ADSystemInfo")
> strComputerDN = objSysInfo.ComputerName
>
> ' Move this computer object to the target OU.
> Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN,
> vbNullString)
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>
>
>
 >> Stay informed about: Move Computer from default OU to another during build proc.. 
Back to top
Login to vote
Jeffrey B

External


Since: Oct 26, 2006
Posts: 3



(Msg. 7) Posted: Thu Oct 26, 2006 12:45 pm
Post subject: Re: Move Computer from default OU to another during build process [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Either or but I prefer during the the building process. This is what I have
so far
Currently sysprep is doing the adding the workstation to the domain part. I
want to be able to do a runonce and move the workstation from the "computers"
container to what ever site it is. I'm sure you already know, by default all
workstation that you add to the domain will first go to the
"Computers"Container.

our Ous are broken down by sites and I would like to move the workstations
base on their prefered site. Also naming convention is site specific...

Thanks,
Jeff

"RC" wrote:

> Jeffrey B,
>
> Are you looking to do this during your build process or are you looking to
> accomplish this on workstations that are already in production?
>
> RC
>
> "Jeffrey B" wrote:
>
> > Hello guys I am also looking for script that moves Computer account to
> > another OU.
> > Ok,
> >
> > Base on the script listed below. How would I start if Im moving a computer
> > account from the "computer container" to let say "SampleOU"
> >
> > Thanks
> >
> > "Richard Mueller" wrote:
> >
> > > >>
> > > > Richard,
> > > >
> > > > Thank you for the reply. Unfortunatly I'm fairly new to these scripting
> > > > methods and don't know how to incorporate the desired destination OU with
> > > > your example.
> > >
> > > Hi,
> > >
> > > I tested the script below (with a different target OU) and it moved the
> > > computer the script was run on into the target OU. Watch for line wrapping:
> > > ====================
> > > Option Explicit
> > > Dim objNewOU, objSysInfo, strComputerDN, objMoveComputer
> > >
> > > ' Bind to target OU, where computer object will be moved.
> > > Set objNewOU = GetObject("LDAP://OU=Sales,dc=MyDomain,dc=com")
> > >
> > > ' Determine Distinguished Name of local computer.
> > > Set objSysInfo = CreateObject("ADSystemInfo")
> > > strComputerDN = objSysInfo.ComputerName
> > >
> > > ' Move this computer object to the target OU.
> > > Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN,
> > > vbNullString)
> > >
> > > --
> > > Richard
> > > Microsoft MVP Scripting and ADSI
> > > Hilltop Lab - http://www.rlmueller.net
> > >
> > >
> > >
 >> Stay informed about: Move Computer from default OU to another during build proc.. 
Back to top
Login to vote
Richard Mueller

External


Since: Jun 03, 2006
Posts: 31



(Msg. 8) Posted: Thu Oct 26, 2006 7:24 pm
Post subject: Re: Move Computer from default OU to another during build process [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I like to create the computer objects in advance, in the OU's I prefer.
Then, when the machines join the domain, they use the existing object in the
correct OU. Is this possible for you?

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"Jeffrey B" wrote in message

> Either or but I prefer during the the building process. This is what I
> have
> so far
> Currently sysprep is doing the adding the workstation to the domain part.
> I
> want to be able to do a runonce and move the workstation from the
> "computers"
> container to what ever site it is. I'm sure you already know, by default
> all
> workstation that you add to the domain will first go to the
> "Computers"Container.
>
> our Ous are broken down by sites and I would like to move the workstations
> base on their prefered site. Also naming convention is site specific...
>
> Thanks,
> Jeff
>
> "RC" wrote:
>
>> Jeffrey B,
>>
>> Are you looking to do this during your build process or are you looking
>> to
>> accomplish this on workstations that are already in production?
>>
>> RC
>>
>> "Jeffrey B" wrote:
>>
>> > Hello guys I am also looking for script that moves Computer account to
>> > another OU.
>> > Ok,
>> >
>> > Base on the script listed below. How would I start if Im moving a
>> > computer
>> > account from the "computer container" to let say "SampleOU"
>> >
>> > Thanks
>> >
>> > "Richard Mueller" wrote:
>> >
>> > > >>
>> > > > Richard,
>> > > >
>> > > > Thank you for the reply. Unfortunatly I'm fairly new to these
>> > > > scripting
>> > > > methods and don't know how to incorporate the desired destination
>> > > > OU with
>> > > > your example.
>> > >
>> > > Hi,
>> > >
>> > > I tested the script below (with a different target OU) and it moved
>> > > the
>> > > computer the script was run on into the target OU. Watch for line
>> > > wrapping:
>> > > ====================
>> > > Option Explicit
>> > > Dim objNewOU, objSysInfo, strComputerDN, objMoveComputer
>> > >
>> > > ' Bind to target OU, where computer object will be moved.
>> > > Set objNewOU = GetObject("LDAP://OU=Sales,dc=MyDomain,dc=com")
>> > >
>> > > ' Determine Distinguished Name of local computer.
>> > > Set objSysInfo = CreateObject("ADSystemInfo")
>> > > strComputerDN = objSysInfo.ComputerName
>> > >
>> > > ' Move this computer object to the target OU.
>> > > Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN,
>> > > vbNullString)
>> > >
>> > > --
>> > > Richard
>> > > Microsoft MVP Scripting and ADSI
>> > > Hilltop Lab - http://www.rlmueller.net
>> > >
>> > >
>> > >
 >> Stay informed about: Move Computer from default OU to another during build proc.. 
Back to top
Login to vote
Jeffrey B

External


Since: Oct 26, 2006
Posts: 3



(Msg. 9) Posted: Thu Oct 26, 2006 7:24 pm
Post subject: Re: Move Computer from default OU to another during build process [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Yes sure do you an example or have one handy that I can look at?

Thanks,
Jeff

"Richard Mueller" wrote:

> I like to create the computer objects in advance, in the OU's I prefer.
> Then, when the machines join the domain, they use the existing object in the
> correct OU. Is this possible for you?
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>
> "Jeffrey B" wrote in message
>
> > Either or but I prefer during the the building process. This is what I
> > have
> > so far
> > Currently sysprep is doing the adding the workstation to the domain part.
> > I
> > want to be able to do a runonce and move the workstation from the
> > "computers"
> > container to what ever site it is. I'm sure you already know, by default
> > all
> > workstation that you add to the domain will first go to the
> > "Computers"Container.
> >
> > our Ous are broken down by sites and I would like to move the workstations
> > base on their prefered site. Also naming convention is site specific...
> >
> > Thanks,
> > Jeff
> >
> > "RC" wrote:
> >
> >> Jeffrey B,
> >>
> >> Are you looking to do this during your build process or are you looking
> >> to
> >> accomplish this on workstations that are already in production?
> >>
> >> RC
> >>
> >> "Jeffrey B" wrote:
> >>
> >> > Hello guys I am also looking for script that moves Computer account to
> >> > another OU.
> >> > Ok,
> >> >
> >> > Base on the script listed below. How would I start if Im moving a
> >> > computer
> >> > account from the "computer container" to let say "SampleOU"
> >> >
> >> > Thanks
> >> >
> >> > "Richard Mueller" wrote:
> >> >
> >> > > >>
> >> > > > Richard,
> >> > > >
> >> > > > Thank you for the reply. Unfortunatly I'm fairly new to these
> >> > > > scripting
> >> > > > methods and don't know how to incorporate the desired destination
> >> > > > OU with
> >> > > > your example.
> >> > >
> >> > > Hi,
> >> > >
> >> > > I tested the script below (with a different target OU) and it moved
> >> > > the
> >> > > computer the script was run on into the target OU. Watch for line
> >> > > wrapping:
> >> > > ====================
> >> > > Option Explicit
> >> > > Dim objNewOU, objSysInfo, strComputerDN, objMoveComputer
> >> > >
> >> > > ' Bind to target OU, where computer object will be moved.
> >> > > Set objNewOU = GetObject("LDAP://OU=Sales,dc=MyDomain,dc=com")
> >> > >
> >> > > ' Determine Distinguished Name of local computer.
> >> > > Set objSysInfo = CreateObject("ADSystemInfo")
> >> > > strComputerDN = objSysInfo.ComputerName
> >> > >
> >> > > ' Move this computer object to the target OU.
> >> > > Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN,
> >> > > vbNullString)
> >> > >
> >> > > --
> >> > > Richard
> >> > > Microsoft MVP Scripting and ADSI
> >> > > Hilltop Lab - http://www.rlmueller.net
> >> > >
> >> > >
> >> > >
>
>
>
 >> Stay informed about: Move Computer from default OU to another during build proc.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
move computer accounts to a new OU - How could I move hundreds of computer accounts in an OU to another OU? When I use the example in" The Portable script Center", it returns "There is no such object on the server", do I need to run it only on the DC? thanks,

move computer account - help - I would like to move a computer account no matter what OU it is in .. I know the dest OU. Keep getting invalid DN error using below.. seems like I was getting close.. ' On Error Resume Next Set objSysInfo = CreateObject("ADSystemInfo") Comp...

Move computer object - Hi All; I was wondering if you can point me to the right direction. I am trying to write a script that will query the a list of computer and find who the users are that are logged into them then move the computer object to user's OU. If the user is....

Move computer accounts into OU - We have decided to clean up our ad and as such need to move all the computer accounts in specific OU's. I can match the user name from the phone book but i wanted to know if there was any way of just moving a bunch of names at one single time.

Bulk move of computer accounts between OU's - Hi, I am very new to scripting. I want to move 500 computers account from one OU to another. I worked on the following script to somehow pass the argument through the command prompt ot text file. ----------------------------- sComputer= "CN=Test&...
   Windows Server (Home) -> Windows Server Scripting All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]