Jump to content


sweety_devil

Move computer to the good OU

Recommended Posts

Dear all,

 

I migrate my computers from XP to Windows 7.

 

I wanted to move the computers with Windows 7 in a new OU.

 

My user has right to add and move computers in AD.

 

But it doesn't work. Do you know why ?

 

I used this script :

 

' //***************************************************************************

' //***************************************************************************

' // ***** Script Header *****

' //

' // Solution: ConfigMgr

' // File: MoveComputerToCorrectOU.vbs

' // Author: Jakob Gottlieb Svendsen, Coretech A/S. http://blog.coretech.dk

' // Purpose: Move computer to the correct OU that remains in variable MachineObjectOU

' // Run inside TS after install

' //

' // Usage: MoveComputerToCorrectOU.vbs

' //

' //

' // CORETECH A/S History:

' // 0.0.1 JGS 17/12/2009 Created initial version.

' // 0.0.2 MIP 17/03/2009 Added feature to add argument to script

' // 0.0.3 JGS 02/12/2010 Changed to ADSystemInfo for the DN retrieval, instead of a homemade function.

' // Thanks to Nico_ at Technet Forums

' //

' // Customer History:

' //

' // ***** End Header *****

' //***************************************************************************

'//----------------------------------------------------------------------------

'// Main routines

'//----------------------------------------------------------------------------

On Error Resume Next

'Get MachineObjectOU Value

Set wshNetwork = CreateObject("WScript.Network")

Set oFso = CreateObject("Scripting.FileSystemObject")

Set objSysInfo = CreateObject( "ADSystemInfo" )

Set ArgObj = WScript.Arguments

'Use first argument as target OU

strMachineObjectOU = ArgObj(0)

strComputerDN = objSysInfo.ComputerName

nComma = InStr(strComputerDN,",")

strCurrentOU = Mid(strComputerDN,nComma+1)

strComputerName = Left(strComputerDN,nComma - 1)

'If current ou is different than target OU. Move object

If UCase(strCurrentOU) <> UCase(strMachineObjectOU) Then

Set objNewOU = GetObject("LDAP://" & strMachineObjectOU)

Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN, strComputerName)

End If

'//----------------------------------------------------------------------------

'// End Script

'//----------------------------------------------------------------------------

 

post-3757-0-81766700-1331629578_thumb.jpg

Share this post


Link to post
Share on other sites

Hi,

I use the same script a lot, are you sure you have delegeted the correct permissions? The user account must have Delete permissions as well.

If you run the script manually with the same user accound does it work then?

Here are the correct permissions documentet:http://blog.coretech.dk/mip/creating-a-joindomain-account-for-use-with-sccm-osd/

 

Regards,

Jörgen

Share this post


Link to post
Share on other sites

I had the same Problem with a script and i solve it by changeing the tasksequencve like this.

 

Before the change: OSD Step -> Conifg Mgr Client -> Script with Domain Acc

With the solution: OSD Step -> Restart -> Config Mgr Client -> Script with Domain Acc

 

The Restart Step solved the problem for me... maybe this helps you ;)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...