PowerShell Genie

Move-ADObject

Use Move-ADObject to move an Active Directory object to a different organizational unit or container.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Move-ADObject

Syntax

1PS> Move-ADObject [-Identity] <ADObject> [-TargetPath] <String> [-TargetServer <String>] [-Server <String>] [-Credential <PSCredential>] [-PassThru] [-WhatIf] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Move-ADObject [-Identity] <ADObject> [-TargetPath] <String> [-TargetServer <String>] [-Server <String>] [-Credential <PSCredential>] [-PassThru] [-WhatIf] [<CommonParameters>]
  1. Stage 1Move-ADObject-Identity -TargetPath -TargetServer -Server -Credential -PassThru -WhatIf

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    Move-ADObject -Identity "CN=SRV01,CN=Computers,DC=corp,DC=local"

    1PS> Move-ADObject -Identity "CN=SRV01,CN=Computers,DC=corp,DC=local" -TargetPath "OU=Servers,DC=corp,DC=local"
    Show reference output

    Sample output · fictional data, shaped like the real thing

    DistinguishedName : CN=SRV01,OU=Servers,DC=corp,DC=local
    DNSHostName       : SRV01.corp.local
    Enabled           : True
    Name              : SRV01
    ObjectClass       : computer
    SamAccountName    : SRV01$

    Get-ADComputer -Properties ProtectedFromAccidentalDeletion

    1PS> Get-ADComputer SRV01 -Properties ProtectedFromAccidentalDeletion | Select-Object ProtectedFromAccidentalDeletion
    Show reference output

    Sample output · fictional data, shaped like the real thing

    ProtectedFromAccidentalDeletion
    -------------------------------
    True
    True

    Select DistinguishedName

    1PS> Get-ADComputer SRV01 | Select-Object DistinguishedName # before and after
    Show reference output

    Sample output · fictional data, shaped like the real thing

    DistinguishedName
    ------------------------------------
    CN=SRV01,OU=Servers,DC=corp,DC=local
    CN=SRV02,OU=Servers,DC=corp,DC=local

    Parameters

    Parameter definitions:

    • -Identity
    • -TargetPath
    • -TargetServer
    • -Server
    • -Credential
    • -PassThru
    • -WhatIf

    Move-ADObject on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Move-ADObject when you need to move an Active Directory object to a different organizational unit or container. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: Access denied can result from protection against accidental deletion or missing delegated rights. Inspect the object's protection and approved delegation instead of disabling safeguards blindly. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Get-ADOrganizationalUnit. Move-ADObject relocates a directory object; Get-ADOrganizationalUnit identifies OU targets. Validate the target distinguished name and the consequences of its linked policies before moving an account. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Move-ADObject reference on Microsoft Learn

    Recap

    Move-ADObject Use Move-ADObject to move an Active Directory object to a different organizational unit or container.

    Next: Get-ADObject
    Genie guideMove-ADObject

    Use Move-ADObject to move an Active Directory object to a different organizational unit or container. The console below is pre-loaded — run it, then change a value and run it again.