VBScript: Move computer object to another OU via Command line parameter

Download “MoveOU_0.0.3_www.coretech.dk.zip” MoveOU_0.0.3_www.coretech.dk_.zip – Downloaded 2928 times – 881 B

UPDATE: New improved script 0.0.3 uploaded. Thanks to Nico_ at Technet Forums!

Hello everyone

My collegue Michael Petersen, needed a script to move computers to another OU, after re-installing them via SCCM/ConfigMgr.

He have written a blog post to show how to use it in a Task Sequence: http://blog.ctglobalservices.com/mip/using-ts-variables-when-running-a-script-under-a-different-account/

therefore i developed this small script

All you needs to do is to run it with the CN for the new OU (without the LDAP://) in the commandline like this:

cscript.exe MoveOU.vbs “OU=HQ,dc=woodgrovebank,dc=com”


By | 2010-03-17T16:30:33+00:00 March 17th, 2010|Scripting & Development|67 Comments

About the Author:

Jakob Gottlieb Svendsen

Twitter: @JakobGSvendsen

Jakob Gottlieb Svendsen is a Microsoft Cloud and Data Center Management MVP (http://mvp.microsoft.com/en-us/default.aspx), Working as Global Lead Developer, Senior Consultant and Trainer at CTGlobal, where he is one of the driving forces in keeping CTGlobal a System Center Gold Partner and member of the System Center Alliance.

Since he started at Coretech in 2007, he has focused on Scripting and Development, primarily developing tools, extensions and scripts for the System Center Suite. His main area is Automation (including OMS/Azure Automation, Service Management Automation, PowerShell and Orchestrator). Another area is Windows Azure Pack / Azure Stack, where he does implementation, development, workshops and presentations. He is a world-wide renowned voice in the Automation field.

He is passionately devoted to the community, to which he contributes by being a moderator at TechNet and sharing his knowledge at http://blog.ctglobalservices.com/jgs

  • Co-founder: PowerShell User Group Denmark
  • Speaker at MMS 2016, Minneapolis (www.mmsmoa.com)
  • SCU Europe 2014, 2015, 2016 (www.systemcenteruniverse.ch)
  • Microsoft TechEd North America 2014, Houston
  • NIC 2012,2013,2014,2015, Oslo (www.nic.com)
  • Microsoft CampusDays 2011, 2013, Copenhagen
  • Microsoft TechDays 2015, Sweden (www.techdays.se)
  • Microsoft Partner Event: New in SC2012 SP1
  • User group meetings (PSUG.DK , SCUG.DK/BE/NO, AZMUG + more)
  • Microsoft Certified Trainer.
  • Microsoft Scripting Guys Forum Moderator

Main working areas:

  • Automation (Azure Automation, SMA, SCO)
  • Windows Azure Pack / Azure Stack
  • System CenterVisual Studio Team Services / Team Foundation Server
  • Development:C#.Net, VB.NET, VBScript, PowerShell, Service Manager, OpsMgr, ConfigMgr
  • Orchestrator
  • Windows Azure Pack / Azure Stack

Training:

  • Azure Automation
  • Service Management Automation
  • System Center Orchestrator
  • PowerShell, VBScript, C#.Net, VB.Net
  • Windows Azure Pack / Azure Stack Development Workshops

67 Comments

  1. Make September 26, 2010 at 4:34 - Reply

    Thanks, very useful !.

  2. Tony October 29, 2010 at 5:00 - Reply

    Thanks so much for posting this! The in-built task sequence steps for joining to domain and specifying OU don’t move to OU if the computer object already exists in AD and is already in an OU. A bit useless! I’ve incorporated this script into my task sequence and it works great. Cheers!

  3. […] solution is using this great VBSscript provided by Coretech.dk you can find it here:http://blog.coretech.dk/scripting/vbscript-move-computer-object-to-another-ou-via-command-line-param… The script will move the computer if it is not already in the specified OU, i was thinking of […]

  4. Jörgen Nilsson December 11, 2010 at 20:14 - Reply

    Great script! Thanks for sharing!
    I wrote a post about how I use it in a Task Seqeunce. http://ccmexec.com/?p=686
    Again, thanks!
    Regards,
    Jörgen

  5. Erik June 23, 2011 at 10:06 - Reply

    Hi! I’m sure this is a great script but I cant’t manage to get it to run in my TS. If I run it manually from the computer it works fine. I also tried to copy it in the TS to the computer and run with command line, no luck. Any suggestions?

    • Jakob Gottlieb Svendsen
      Jakob Gottlieb Svendsen June 23, 2011 at 13:49 - Reply

      Hello Erik

      Since you have not put any error message / log output in your comment, i have no chance of knowing that problem you have

      i suggest to look at this article about running commands with variables in TS
      http://blog.coretech.dk/mip/using-ts-variables-when-running-a-script-under-a-different-account/

      and also the above guide in Jörgen’s comment
      http://ccmexec.com/?p=686

      • Lubo August 25, 2011 at 3:04 - Reply

        Hi Jakob
        Script works by itself when running out of fully operational Win 7 OS, but when running from the task in a TS, it fails with this error “CScript Error: Can’t find script engine “VBScript” for script …

        I am using the same method depicted at:http://ccmexec.com/2010/12/move-computer-to-the-correct-ou-during-deployment/

        I should mention, I am using domain admin account to run the script out of task in my Windows 7 Image deployment Task Sequence ….not the computer system account. All my tasks executing VB Scripts run perfectly well in the same TS (while deploying the very same image) when running in the context of the system account

        Interesting: when I tried to deploy one of my test Win 7 images using the same TS script worked.
        Is my production Image broken?

        Thanks

        • Kalin Tashev October 18, 2016 at 14:08 - Reply

          Hi Lubo,

          Are you loading the user profile of the account used to run the script?
          I had similar failures with other VBS scripts I am running in another user context and they got resolved by loading the user’s profile.

  6. Erik June 24, 2011 at 9:43 - Reply

    Hi, thank you for your reply. No error messages, I have put this as the last step after installing SW. Some lines from the SMSTS log (If this is to much, let me know :):
    Variable name: _SMSTSRunCommandLineAsUser TSManager 24.06.2011 08:08:38 336 (0x0150)
    Variable name: SMSTSRunCommandLineUserName TSManager 24.06.2011 08:08:38 336 (0x0150)
    Variable name: SMSTSRunCommandLineUserPassword TSManager 24.06.2011 08:08:38 336 (0x0150)
    Action command line: smsswd.exe /run:P010003C cscript.exe MoveOU.vbs “OU=Desktop,OU=Computers,OU=xxxxxxxx,dc=xxxxx,dc=no” TSManager 24.06.2011 08:08:38 336 (0x0150)

    • erik September 22, 2011 at 17:39 - Reply

      Hi again,
      Finally got it working,:). Removed the dashes in the string and retyped them, must have been a copy error or a typo i guess. cscript.exe MoveOU.vbs “OU=Desktop,OU=Computers,OU=xxxxxxxx,dc=xxxxx,dc=no”
      Thanks!

  7. Mike August 23, 2011 at 18:35 - Reply

    I am trying to test it now. But i do have a question. I have a staging OU, so i can run this script and move the client to staging OU “in case if client is already in AD” and then run the script as the very last step to move in to the perm OU?

  8. Mike August 23, 2011 at 19:13 - Reply

    When i run it manually i get no error msg but its not moving client to a new OU. When i try to run it from the TS the script is failing.
    cscript.exe “%SCRIPTROOT%MoveOU.vbs “OU=Windows7,OU=***,OU=***,OU=***,DC=***,DC=***,DC=com”

  9. Bill August 26, 2011 at 21:04 - Reply

    Thanks for sharing this, it was exactly what I needed to resolve issues with GPO doing unwanted things during the OSD process. Works great for us

  10. Max August 30, 2011 at 10:48 - Reply

    MDT users: which part of the task sequence are you guys adding the vbs to?

  11. Ben August 31, 2011 at 21:35 - Reply

    This script runs great once I copy it to the local machine. The issue that I am having is that I am PXE booting a PC and it is pulling a MINIT… computername. How can I add a variable to use when searching AD instead of using the currenlty assigned computername?

    I am fairly new to scripting, but hacking away everyday.

    Thanks.

  12. Ben August 31, 2011 at 21:37 - Reply

    P.S.

    To those who can not run it inside of a TS, I have resolved this by copying it to the local C:, running it, and then deleted it from the C: in my TS.

  13. Jakob Gottlieb Svendsen
    Jakob Gottlieb Svendsen September 1, 2011 at 10:48 - Reply

    @Ben

    thnx for sharing the fix about the TS, before i got to reply.
    It is always a good idea to copy script to local PC if you are having problems

    about the computername

    just change
    strComputerDN = objSysInfo.ComputerName

    to

    strComputerDN = “CN=MyPC,DC=Contoso,DC=com”

    unfortunately you will have to use the FQDN and not the NEtbios computername

    if you want to search by name instead you can implement at script like this one

    http://gallery.technet.microsoft.com/scriptcenter/0d865bfb-bb10-4147-86c2-f2b68a438de9

  14. Ben September 1, 2011 at 16:23 - Reply

    @Jakob

    thnx for the quick reply. I think that I worded my question wrong. I am wanting a popup box to ask me for the desired new name of the PC. Then I want the script to move that PC to a specific OU. Then that same name should be passed to the UDI for the computer name portion. Below is what I have so far. It does pass the name to the UDI, but it does not move the PC to the correct OU. All of this is being run in a TS.

    On Error Resume Next

    ‘Added variables
    Dim OSDComputerName

    ‘Popup to get OSDComputername
    strComputer = InputBox(“Enter Computer Name:”)
    Set myTSEnv = CreateObject(“Microsoft.SMS.TSEnvironment”)
    myTSEnv(“OSDComputerName”) = strComputer

    ‘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
    strComputerDN = objSysInfo.OSDComputerName

    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

    • whelen May 15, 2013 at 10:58 - Reply

      Hi ben,
      How you solve in the end?
      Could you share?

  15. Jakob Gottlieb Svendsen
    Jakob Gottlieb Svendsen September 2, 2011 at 9:05 - Reply

    hello ben

    there are sevreal problems in your approach.

    1. You cannot show a messagebox or any other interaction with the user from a TS. It is not possible, since the TS does not run in the same context as the user (it runs in administrive context / local_system). at least that is what the documentation says, so i always keep from it, but maybe it does work on some machines?

    2. You are assigning a computername to myTSEnv(“OSDComputerName”) but using it as objSysInfo.OSDComputerName ?

    3. what kind of computername are you typing in ? is it DistinguishedName as required?

    – Jakob

  16. rdw October 6, 2011 at 15:30 - Reply

    I can’t seem to get this to work even from the command prompt. Using 0.0.3 version

    Usage:
    cscript.exe moveou.vbs “OU=XXXX,OU=XXX,OU=XX,DC=XXX,DC=XXX,DC=XXX”
    used dsquery computer to verify LDAP ifo.

    Any way to troubleshoot this with a log or something?
    Thanks.
    Robert

  17. jan November 10, 2011 at 15:52 - Reply

    Hello
    I’m trying to use this script in a sccm TS. This TS is migrating a machine from XP to win7 and is using the MDT integrated DB to change the computername. The new computerobject is than put into the correct OU in AD.
    What I want to do is to use a script like this to move the old computerobject to a OU for migrated computers.
    I have noticed that the old computername is stored in the SCCM variable _SMSTSMachineName during the complete TS. So I am thinking of running this like:
    cssript.exe moveou.vbs “OU-….” %SMSTSMachineName%

    My skills in vb scripting are limited, but so far I have come up with the following change to the script:
    ‘Use first argument as target OU
    strMachineObjectOU = ArgObj(0)
    strComputerDN = ArgObj(1)

    So far this is not working for me. Any ideas

  18. Magnus November 18, 2011 at 8:57 - Reply

    @Ben.

    You could use a HTA to pass variables from HTA to the TS.
    Heres a great post on it http://www.windows-noob.com/forums/index.php?/topic/3245-how-can-i-pass-values-from-the-hta-to-the-task-sequence/

    i also use a script to ask for a computer if the computer name begins with “minint” great when you install a new computer.

  19. Mike March 15, 2012 at 23:09 - Reply

    Does anyone has this working?
    I am trying to run this manually from the local script. Not getting any errors. However the workstation is not moving to a new OU.

    cscript.exe MoveOU.vbs “OU=Windows7,OU=**,OU=**,OU=**,DC=**,DC=**,DC=com”

  20. Mike March 15, 2012 at 23:24 - Reply

    Sorry for not giving more information.

    I am getting an error on the following line:
    Set objNewOU = GetObject(“LDAP://” & strMachineObjectOU)

    (null): A referral was returned from the server

    • Claus Codam March 17, 2012 at 1:59 - Reply

      Hey Mike,

      The error probably relates to incorrect DC statements. Please check that you haven’t made a typo or entered any wrong information.

      “A referral was returned from the server” basically means that the LDAP server you contacted, doesn’t recognize the requested DC path.

  21. Sundeep July 26, 2012 at 4:32 - Reply

    Hi Jakob

    Great script! Thanks for sharing!

    It works for me great when i am rebuilding a existing PC or Laptop which is already in Active Directory

    cant get it to work when doing bare metal PC. i am getting error 0x80004005 . can this script work on bare metal

    thanks for you help

    • Jakob Gottlieb Svendsen
      Jakob Gottlieb Svendsen July 26, 2012 at 10:29 - Reply

      hello Sundeep

      thank you 🙂

      If it is a new PC, is there a AD object that it can move?

      please explain more about what you are trying to do, and how you do it.

      • Sundeep Patel August 5, 2012 at 22:50 - Reply

        Hi Jakob

        Thanks for replying back . i am trying to build a brand new PC out of the box . there is no AD object for this machine . i want to use your script to move the PC to a particular OU when building via task sequence (SCCM)

        thanks for you help

  22. Ronald October 10, 2012 at 19:48 - Reply

    Can this script be run from a local machine account?

    Could it prompt for a domain user name/password with rights to move computers to OUs?

  23. Roel Janssens December 12, 2012 at 12:15 - Reply

    Thanks for this one!

  24. whelen May 13, 2013 at 11:03 - Reply

    Hi Jacob,
    I was face error on move desktop OU as using your script.
    MY workstationw as stuck in STaging OU….

    But i can do the manually move using your script.
    My Error as : Litetouch Deployment Failed, Return code = -2147467259 0x80004005
    Failed to run the action: Custom move acct to laptop OU.

    FYI, its working lastime…
    Dont know why recently failed to move at staging OU to laptop/Dekstop OU….

    • Jakob Gottlieb Svendsen
      Jakob Gottlieb Svendsen May 13, 2013 at 11:05 - Reply

      hello whelen

      0x80004005 is access denied.

      i believe you can a permission problem. Try running the script manully as the user you use in the task sequence.

  25. whelen May 14, 2013 at 3:01 - Reply

    Hi Jakob,
    Thanks for your reply.
    your r right that code was access issue.
    I try to using other domain admin account also not luck.
    Funny was its sometime can move…sometimes fail…:”(

  26. whelen May 14, 2013 at 7:36 - Reply

    Hi Jakob,
    Is that any ways i can verified whether the task sequenceof run this step as the following account?
    Because i can manually move, but using it was failed…

  27. whelen May 16, 2013 at 3:39 - Reply

    Hi Jokob,
    I saw a reply as:
    Ben says:
    31st August 2011 at 21:37
    P.S.

    To those who can not run it inside of a TS, I have resolved this by copying it to the local C:, running it, and then deleted it from the C: in my TS.

    How can i copy the MoveOU.vbs to C: in my ts?

  28. User May 24, 2013 at 15:46 - Reply

    Max says:
    30th August 2011 at 10:48
    MDT users: which part of the task sequence are you guys adding the vbs to?

    I never saw an answer to Max’s question. Which is the same one I have. The script works, but my policies (legal notice) are applied before the script is run. After I click okay to accept the legal notice the script moves the computer to a staging OU.

    Thanks

  29. Nike Air Max May 31, 2013 at 6:08 - Reply

    After going over a few of the blog posts on your site, I truly
    like your technique of blogging. I saved it to
    my bookmark website list and will be checking back in the near future.

    Take a look at my website as well and let me know what you
    think.

  30. Roel September 17, 2013 at 12:10 - Reply

    Each time I get an errorcode 1 and the machine is not moved within AD (permissions for account are correct).

    What does errorcode 1 mean?

    • Jakob Gottlieb Svendsen
      Jakob Gottlieb Svendsen September 17, 2013 at 13:20 - Reply

      hello.

      error code 1 can be alot of things (vbscript is not good at return codes)

      please try removing the “On error resume next” and please write the detailed error message and code.

  31. Phil October 29, 2013 at 9:33 - Reply

    Hi Jakob,
    What I have to change if I want to set the destination OU as a string inside the script and not as a command line parameter?
    I’ve done a lot of attemps but I cannot make it works.
    Thank you,
    Phil

    • Jakob Gottlieb Svendsen
      Jakob Gottlieb Svendsen October 29, 2013 at 10:36 - Reply

      hello Phil

      These are the lines that handles the arguments from commandline:

      Set ArgObj = WScript.Arguments
      ‘Use first argument as target OU
      strMachineObjectOU = ArgObj(0)

      you can remove these lines and write your OU directly into the variable

      strMachineObjectOU = “OU=myOU,CN=mydomain,CN=com”

  32. Mike November 21, 2013 at 11:45 - Reply

    This is a popular script!!! So popular in fact that others are now claiming the work to be theirs!

    http://www.intrntpirate.com/?p=199

  33. Ryan December 17, 2013 at 4:48 - Reply

    Hi,
    After the new machine is built, we require it to maintain the domain group memberships it had before the migration.
    What would be the best way to achieve this?

  34. JM April 24, 2014 at 21:27 - Reply

    Hi! We are deploying our computers with ZENworks and not SCCM, therefor I cannot specify the use of network credentials to run the script.

    Is there a way to hardcode in the script a username and password?

    Thanks!

    JM

  35. Jared May 19, 2014 at 6:21 - Reply

    Wow, great script. Thanks.

    I do have a question though. I am using this script in my unattend.xml firstlogoncommands to change the computers OU. I’ve got it to work but in order for it to move the computer to the correct OU I have to login using my administrator account. After I login it magically moves to the new OU. I am deploying using WDS.

    Do you have any ideas on what the issue might be?

  36. Jack Fetter February 22, 2015 at 21:31 - Reply

    For those having issues with the script not working that are sure the script is running in the right place within the OSD and with an account that has proper permissions, check the “quote” characters. If you copied and pasted using the “Usage example” at the top of this page, the quote characters are not correct 😉

    cscript.exe MoveOU.vbs “OU=HQ,dc=woodgrovebank,dc=com”

    Quotes should be ” not ”

  37. basti September 1, 2015 at 10:19 - Reply

    Hey, i have tried to get your script working for days now…
    I am very frustrated about my TS. In my full installed Win 8.1, the script works perfectly! Only in my TS the Script won’t work….
    I have tested many solutions found in the web.

    – Testing various orders from TS
    – Doing Restart before or After the Script
    – Running the Script with a Batch file

    I have cleared some erros. but it doesnt work yet.

    I have copied the script locally and run it locally. Actually i just become this error:

    Expand a string: WinPEandFullOS TSManager 01.09.2015 10:05:32 2220 (0x08AC)
    Executing command line: smsswd.exe /run: cscript.exe %SystemDrive%WindowsCCMMoveOu.vbs “OU=A-A A,OU=BBB,OU=CCC,dc=DDD,dc=EEE” TSManager 01.09.2015 10:05:32 2220 (0x08AC)
    [ smsswd.exe ] InstallSoftware 01.09.2015 10:05:32 2624 (0x0A40)
    PackageID = ” InstallSoftware 01.09.2015 10:05:32 2624 (0x0A40)
    BaseVar = ”, ContinueOnError=” InstallSoftware 01.09.2015 10:05:32 2624 (0x0A40)
    ProgramName = ‘cscript.exe C:WindowsCCMMoveOu.vbs “OU=A-A A,OU=BBB,OU=CCC,dc=DDD,dc=EEE”‘ InstallSoftware 01.09.2015 10:05:32 2624 (0x0A40)
    SwdAction = ‘0001’ InstallSoftware 01.09.2015 10:05:32 2624 (0x0A40)
    Getting linked token InstallSoftware 01.09.2015 10:05:32 2624 (0x0A40)
    Get RunAs private desktop SMSTS-354609SMSTSDesktop InstallSoftware 01.09.2015 10:05:35 2624 (0x0A40)
    Run command line under a user account InstallSoftware 01.09.2015 10:05:35 2624 (0x0A40)
    Command line for extension .exe is “%1” %* InstallSoftware 01.09.2015 10:05:35 2624 (0x0A40)
    Set command line: Run command line InstallSoftware 01.09.2015 10:05:35 2624 (0x0A40)
    Working dir ‘c:WindowsCCM’ InstallSoftware 01.09.2015 10:05:35 2624 (0x0A40)
    Executing command line: Run command line InstallSoftware 01.09.2015 10:05:35 2624 (0x0A40)
    Create a process under given user token InstallSoftware 01.09.2015 10:05:35 2624 (0x0A40)
    Process completed with exit code 1 InstallSoftware 01.09.2015 10:05:36 2624 (0x0A40)
    Command line returned 1 InstallSoftware 01.09.2015 10:05:36 2624 (0x0A40)
    Process completed with exit code 1 TSManager 01.09.2015 10:05:37 2220 (0x08AC)

    What can I do now? Can you help me out of this?

    Thanks in Advance 🙂

  38. Andrew September 29, 2015 at 13:46 - Reply

    This script works great when I run it manually. But I can’t for the life of me get it to work within a MDT TS. It always fails with return code -2147467259 0x80004005
    I’m starting to think it’s the “Run this step as the following account” function that isn’t working as it should.

    I know that the account I’m using under “Run this step as the following account” has the correct permissions. Because if I manually run CMD as a different user and use the same account and credentials that I use within the TS and just run “cscript.exe MoveOU.vbs “OU=myOU,CN=mydomain,CN=com”” it moves the computer object just fine.
    But just to be sure it’s not a permission problem I’ve even tried using the Domain Admin account in the TS to move the computer object, but alas…

    For those of you that actually got the script to work within a TS. Are you using MDT or SCCM and which version?
    I’m using MDT 2013 Update 1 build 8298.

    I’ve tried to copy the script to C:MININT and have the TS run the script from that location and I’ve tried running it from %scriptroot% but I always get the same error.

  39. Emil September 14, 2016 at 13:28 - Reply

    Hi,

    I am trying to get this to work in a TS with UDI.

    I am using this command line: cscript.exe MoveOU.vbs “%OSDDomainOUName%”

    The script runs and TS finishes with no errors, but the computer is not moved to the correct OU… Am I doing anything wrong?

  40. Jeff November 4, 2016 at 8:16 - Reply

    hi Jakob

    thanks for the move computer object to another OU via Command line parameter.

    is there a script to delete computer object from AD via command line parameter?

  41. priMDT December 21, 2016 at 15:10 - Reply

    Does it work on Windows 10 ? It is not working for me.

  42. Surjeet April 3, 2017 at 4:24 - Reply

    Yes, it does work on Windows 10 and the only other thing that I’ve noticed with this script is that if you install applications and then later in the TS you use this script to move the machine – it would fail! So to get around it, I just used the script right after the drivers step followed by applications.

  43. lcruisader October 10, 2017 at 14:40 - Reply

    Running this script outside of TS on Windows 10 1607 x64 in a domain Admin command prompt. I get this error:
    C:\dev\cscript PCmove.vbs “OU=Shiney,DC=Contoso,DC=com”
    Microsoft (R) Windows Script Host Version 5.812
    Copyright (C) Microsoft Corporation. All rights reserved.

    C:\dev\PCmove.vbs(45, 24) Microsoft VBScript compilation error: Expected ‘Then’

    That refers to this section in the code (<&gt):
    ‘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
    I have not edited any part of the script.
    Any ideas?

  44. lcruisader October 10, 2017 at 14:51 - Reply

    Disregard. it was a bad copy ‘n paste. I saw after my posting the portion of my post changed to which was not what my vbs had. I copied the script code from: https://www.windows-noob.com/forums/topic/5183-move-computer-to-the-good-ou/ and voila! Tested and verified and my computer moved OU’s. Onto testing it in the T.S. yay!

  45. Sid October 15, 2017 at 0:04 - Reply

    Hello
    nothing happens when I run it from command prompt.
    has anyone figured out how this should be used in MDT inside the TS?
    thanks

Leave A Comment