locked
Move computer account to a differenct ou using powershell RRS feed

  • Question

  • Looking for a quick script usig powershell to move computers to new ou. Dave
    Thursday, August 11, 2011 5:00 PM

Answers

All replies

  • Look into the Quest AD CmdLets. They can be a great help and are free.

    http://www.quest.com/powershell/activeroles-server.aspx

     


    jv
    • Marked as answer by IamMred Wednesday, August 17, 2011 4:35 AM
    Thursday, August 11, 2011 5:16 PM
  • To jrv's point:

    Add-PSSnapin Quest.ActiveRoles.ADManagement
    $Computer = 'testpc01'
    $NewOU = 'contoso.com/someOU'
    Get-QADComputer $Computer | Move-QADObject -NewParentContainer $NewOU
    

    That will load the Quest tools, verify testpc01 and then move it to the new OU, 'contoso.com/someOU'.


    If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer".

    Rich Prescott | MCITP, MCTS, MCP

    Blog | Twitter: @Arposh | Powershell Client System Administration tool
    • Proposed as answer by Rich Prescott Thursday, August 11, 2011 9:18 PM
    • Marked as answer by IamMred Wednesday, August 17, 2011 4:35 AM
    Thursday, August 11, 2011 9:18 PM
  • Here is another option using DSQUERY command:

    http://portal.sivarajan.com/2011/07/move-computer-objects-based-on.html

    http://portal.sivarajan.com/2011/03/computer-cleanup-script-batch-file.html

    dsmove <Computer> -newparent OU=NewOU,DC=Domain,DC=com


    Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX

    Blogs - http://blogs.sivarajan.com/
    Articles - http://www.sivarajan.com/publications.html
    Twitter: @santhosh_sivara - http://twitter.com/santhosh_sivara
    This posting is provided AS IS with no warranties,and confers no rights.
    • Proposed as answer by Rich Prescott Thursday, August 11, 2011 9:43 PM
    • Marked as answer by IamMred Wednesday, August 17, 2011 4:35 AM
    Thursday, August 11, 2011 9:34 PM
  • Here is another option using DSQUERY command:

    http://portal.sivarajan.com/2011/07/move-computer-objects-based-on.html

    http://portal.sivarajan.com/2011/03/computer-cleanup-script-batch-file.html

     


    Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX

    Blogs - http://blogs.sivarajan.com/
    Articles - http://www.sivarajan.com/publications.html
    Twitter: @santhosh_sivara - http://twitter.com/santhosh_sivara
    This posting is provided AS IS with no warranties,and confers no rights.

    dsmove <Computer> -newparent OU=NewOU,DC=Domain,DC=com


    The only issue with dsmove is that it only exists, by default,  on a DC.  It is, however, the most obtainable solution. Just install the AD tools from the CD/DVD.

    Except for this one which works from anywhare in the domain with no added software and in PowerShell.

    function Move-Computer($computername,$targetOU){
       $result=([adsisearcher]"cn=$computername").FindOne()
       $computer.MoveTo([adsi]$targetOU)
    }
    
    Move-Computer system01 'LDAP://ou=someou,....'
    
    
    
    

     


    jv
    • Proposed as answer by Richard MuellerMVP Sunday, August 14, 2011 3:52 PM
    • Marked as answer by IamMred Wednesday, August 17, 2011 4:35 AM
    Thursday, August 11, 2011 10:06 PM
  • natively.

    Get-ADComputer servername | Move-ADObject -TargetPath "ou=something,dc=mydomain,dc=com"


    Dan
    • Marked as answer by IamMred Wednesday, August 17, 2011 4:35 AM
    Friday, August 12, 2011 12:58 PM
  • Hi Dan,

    Yup- I was using this:

    $NewOU='ou=toxic test - user,dc=euroinv,dc=com'
    Get-QADComputer $computer | Move-QADObject -NewParentContainer $NewOU

    I think gpupdate /force is running, but activating office doesn't seem to (it doesn't seem to work through sysprep first logon commands or even when I did it through batch, so I'm not worried about this one, really), netsh gives me this: "An error occurred while attempting to connect to the remote computer. Make sure that the Windows Firewall service on the remote computer is running and configured to all
    ow remote management, and then try your request again," & restarted winrm gives me this: "Get-Service : Cannot open Service Control Manager on computer 'nyc-bfq4m1'. This operation might require other privileges" -- I'm running this as an admin.

    The other sort of odd thing is that ps remoting is configured in the policy that this computer is receiving and I can't even invoke-command at this point. There have never been issues up to now with this either, as far as computers under this specific policy having problems with powershell remoting, but that's somewhat unrelated, at least for now.

    Thursday, August 29, 2013 6:54 PM
  • For Office activation I would checking the Office 2010/2013 forum.  Office can  be activated in an enterprise via GP.  This is the preferred method.

    ¯\_(ツ)_/¯

    Thursday, August 29, 2013 6:58 PM
  • I have the plugin for Office and have some other configs through GP for it, so I will take a look.

    I actually just placed a startup script under machine pol to activate, so let's see what happens there. As for netsh, this may be more of a infrastructure/network thing rather than anything else. I'll try and work out the kinks and report back.

    • Edited by Sentri7 Thursday, August 29, 2013 7:20 PM
    Thursday, August 29, 2013 7:03 PM
  • Look into the Quest AD CmdLets. They can be a great help and are free.

    http://www.quest.com/powershell/activeroles-server.aspx

     


    jv

    Hi,

    Is the Quest AD cmdlet is still free and compatible with Powershell 5.0 ?


    /* Server Support Specialist */

    Tuesday, January 19, 2016 3:13 AM
  • Look into the Quest AD CmdLets. They can be a great help and are free.

    http://www.quest.com/powershell/activeroles-server.aspx

     


    jv

    Hi,

    Is the Quest AD cmdlet is still free and compatible with Powershell 5.0 ?


    /* Server Support Specialist */

    No longer used with PowerShell.  We use RSAT now.  It is free and it is D CmdLets.


    \_(ツ)_/

    Tuesday, January 19, 2016 3:33 AM