Move users from OU RRS feed

  • Question

  • Good afternoon.

    I have to move many users from different OUs to the same OU, and I cannot get it to work correctly.

    I just want to just give it the user's full name and destination OU, I can move them, but I'm not able.

    The CSV file I have is the following:

    ParentContainer,Name,FirstName,LastName,DisplayName,,Veronica  Castro,Veronica ,Castro,Veronica  Castro,

    The script is:

    Import-Csv "C:\Users\Administrador\Desktop\Prueba\usuarios.csv" | foreach {Move-ADObject -Identity $ -Targetpath $_.ParentContainer}

    The error is:

    PS C:\Users\Administrador\Desktop\Prueba> .\mover.ps1
    Move-ADObject : Cannot find an object with identity: 'Veronica Castro' under: 'DC=1,DC=2,DC=3'.
    At C:\Users\Administrador\Desktop\Prueba\mover.ps1:1 char:76
    + Import-Csv "C:\Users\Administrador\Desktop\Prueba\usuarios.csv" | foreach {Move- ...
    +                                                                            ~~~~~
        + CategoryInfo          : ObjectNotFound: (Veronica Castro:ADObject) [Move-ADObject], ADIdentityNotFoundException
        + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,M

    PS C:\Users\Administrador\Desktop\Prueba>

    How can i do to solve it?

    Thanks so much.

    Thursday, May 14, 2020 3:23 PM

All replies

  • "Name" is n ot an identity.  You must use SamAccountName or DistinguishedName or other identifier.

    Please take the time to read the full help for the CmdLets before trying to use them.  It will save you a lot of time.


    Thursday, May 14, 2020 3:58 PM
  • Hi jrv,

    I change the option that you said me but it does not work:

    Import-Csv "C:\Users\Administrador\Desktop\Prueba\usuarios.csv" | foreach {Move-ADObject -Identity $_.SamAccountName-Targetpath $_.ParentContainer}

    My CSV is:


    I tested also with this CSV and it does not work:



    Any idea?

    Thanks so much

    Thursday, May 21, 2020 5:51 PM
  • Your CSV is broken. It cannot have a trailing comma in the header.

    The ParentContainer is not formed as a correct DistinguishedName.


    Thursday, May 21, 2020 5:59 PM
  • How could i do to solve this?

    Could you be so kind to give me any idea? Please

    Friday, May 22, 2020 5:06 PM
  • Fix your CSV file so that it is a legal CSV file:

    Comma-separated values - Wikipedia


    Friday, May 22, 2020 6:43 PM