I've did a search through this forum for this, but the methods I've found haven't worked out for me. Does anyone here do this currently in their MDT? If so can you please share how you are pulling this off. I found a .vbs script that will work if I run it
manually from a command prompt with the same credentials I have set to run as in the TS. But I cannot get it to run during the task sequence. Below is the vbs script and showing how I have had it listed in the TS. I have it set to run under a service account
that has domain rights to move to OUs.
I have set it to run in the task sequence the following ways.
cscript.exe "%SCRIPTROOT%\MoveOU.vbs" "OU=TEST OU,DC=MYDOMAIN,DC=COM"
cscript.exe %SCRIPTROOT%\MoveOU.vbs "OU=TEST OU,DC=MYDOMAIN,DC=COM"
\\mdtserver\deployshare$\scripts\MoveOU.vbs "OU=TEST OU,DC=MYDOMAIN,DC=COM"
Here is the 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.1JGS 17/12/2009 Created initial version.
' // 0.0.2MIP 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
'//--------------------------------------------