This script will be useful if you want to move computer objects in the Active Directory filtered by name to a destination OU

Script :

$computerstomove = Get-ADComputer -LDAPFilter "(name=Desktop00*)" -SearchBase "CN=computers,DC=domain,DC=local,DC=net"
foreach ($computertomove in $computerstomove) {
	Move-ADObject $computertomove -TargetPath "OU=DestinationOU,DC=domain,DC=local,DC=net"

Moves an Active Directory object or a container of objects to a different container or domain.


Move-ADObject [-Identity]  [-TargetPath]  [-AuthType { | }] [-Credential ] [-Partition ] [-PassThru] [-Server ] [-TargetServer ] [-Confirm] [-WhatIf] []
  • Identity
  • TargetPath
  • AuthType
  • Credential
  • Partition
  • PassThru
  • Server
  • TargetServer
  • Confirm
  • WhatIf

Detailed Description

The Move-ADObject cmdlet moves an object or a container of objects from one container to another or from one domain to another.

The Identity parameter specifies the Active Directory object or container to move. You can identify an object or container by its distinguished name (DN) or GUID. You can also set the Identity parameter to an object variable such as $, or you can pass an object through the pipeline to the Identity parameter. For example, you can use the Get-ADObject cmdlet to retrieve an object and then pass the object through the pipeline to the Move-ADObject cmdlet. You can also use the Get-ADGroup, Get-ADUser, Get-ADComputer, Get-ADServiceAccount, Get-ADOrganizationalUnit and Get-ADFineGrainedPasswordPolicy cmdlets to get an object that you can pass through the pipeline to this cmdlet.

The TargetPath parameter must be specified. This parameter identifies the new location for the object or container.

Move computer objects to another Active Directory OU

7 thoughts on “Move computer objects to another Active Directory OU

  • October 9, 2015 at 3:50 pm

    Thanks for the script and its working fine.

    Its fulled my requirement.

  • April 28, 2016 at 10:03 am

    What if we have a multiple TargetPath?

    • April 28, 2016 at 3:27 pm

      Hello izzi,

      Could you please give me more information on what you want to do ? The current script parse a list of computers and move them one by one to the path indicated in the parameter TargetPath. If you need more than one Targetpath, you will need to set an array with the computer names and for each of them, the targetpath you want.

      Tell me if you need help…

  • January 30, 2018 at 12:23 pm

    Could you please confirm whether the above would also work if we want to move the computer object from an existing OU to a new AD group.

  • June 13, 2018 at 4:16 pm

    This sorted out an issue we were facing. Thank you very much

  • June 15, 2018 at 11:19 pm

    Hi Nicholas

    How can we do modify script to do below things?

    1. Query AD for computer name beginning with “ABC-” and move them to OU “ABC”
    2. Query AD for computer name beginning with “DEF-” and move them to OU “DEF”

    We have group policy that’s unique for each OU.



Leave a Reply

Your email address will not be published.