Jump to content

Sign in to follow this  

Move OU during TS

Recommended Posts



I'm trying to image existing machines to Windows 10 which also includes moving to a separate OU. I understand from my bit of Googling that an SCCM TS is unable to move OU's through normal tasks for exisiting device records.


I found that it is possible through a VBscript, however this seems to be where I'm running into an error. I can't find a definitive guide on how to use this.


I used a script found over at http://blog.coretech.dk/jgs/vbscript-move-computer-object-to-another-ou-via-command-line-parameter/


The script is:




' //***************************************************************************
02.' //***************************************************************************
03.' // ***** Script Header *****
04.' //
05.' // Solution: ConfigMgr
06.' // File: MoveComputerToCorrectOU.vbs
07.' // Author: Jakob Gottlieb Svendsen, Coretech A/S. http://blog.coretech.dk
08.' // Purpose: Move computer to the correct OU that remains in variable MachineObjectOU
09.' // Run inside TS after install
10.' //
11.' // Usage: MoveComputerToCorrectOU.vbs
12.' //
13.' //
14.' // CORETECH A/S History:
15.' // 0.0.1 JGS 17/12/2009 Created initial version.
16.' // 0.0.2 MIP 17/03/2009 Added feature to add argument to script
17.' // 0.0.3 JGS 02/12/2010 Changed to ADSystemInfo for the DN retrieval, instead of a homemade function.
18.' // Thanks to Nico_ at Technet Forums
19.' //
20.' // Customer History:
21.' //
22.' // ***** End Header *****
23.' //***************************************************************************
25.'// Main routines
28.On Error Resume Next
30.'Get MachineObjectOU Value
31.Set wshNetwork = CreateObject("WScript.Network")
32.Set oFso = CreateObject("Scripting.FileSystemObject")
33.Set objSysInfo = CreateObject( "ADSystemInfo" )
34.Set ArgObj = WScript.Arguments
36.'Use first argument as target OU
37.strMachineObjectOU = ArgObj(0)
38.strComputerDN = objSysInfo.ComputerName
40.nComma = InStr(strComputerDN,",")
41.strCurrentOU = Mid(strComputerDN,nComma+1)
42.strComputerName = Left(strComputerDN,nComma - 1)
44.'If current ou is different than target OU. Move object
45.If UCase(strCurrentOU) <> UCase(strMachineObjectOU) Then
46.Set objNewOU = GetObject("LDAP://" & strMachineObjectOU)
47.Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN, strComputerName)
48.End If
51.'// End Script


I changed the two LDAP:// addresses to the OU where I wish to move it and saved it as a VBscript. I moved it to my sources folder and created a package. Creating a package is usually where I get hung up, truthfully.


To create the package I:


Checked source files, pointed it at the folder containing the VBscript. Choose to create a "Standard Program". I name it, set the command line as "cscript Move.vbs" have it run minimized, whether or not a user is logged in and with administrative rights. I then finish up the package.


I've then inserted it into the TS as seen in the pictures below. I believe I'm probably just messing up at one or two avenues and it's causing me 4-5 hours worth of wait. (I have to image back to W7, customize it a bit and then run the W10 TS in hopes USMT functions as intended.)


The task sequence is failing when it gets to that step with an error of 0x80004005 per the log. I can successfully image back to Windows 7 without an error, so I know it's not a laptop configuration issue but assumingly my OU move error.


Share this post

Link to post
Share on other sites

When you say "move" it is actaully delete the old machine opbject and create a new machine object (with same name) but in a different OU?

If the account adding the machine account got permission to write to the OU it can do so, but it fails if the same name exist already in another OU if same domain.

So if you can have the machine account deleted in the begning of your task sequence I think you be just fine to "move" the machine account.


Sorry no help on the VBS script etc just giving another option.

Share this post

Link to post
Share on other sites

Move as in it automates the moving using a domain admin account to move the record to the target OU. Deleting the record earlier in the task sequence is also an option, but also requires the use of a script - of which I'm a bit more hesitant with deleting of a record especially when I'm struggling with the moving of one. I'm gonna keep giving it a look to see if I can find an alternative as this is the only thing holding me up now. Thanks for the help and quick reply.

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.

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.

Sign in to follow this  

  • Create New...