locked
move user to correct based on csv file RRS feed

  • Question

  • I have a CSV file contains user's login ID and location information. I need to move users to the correct OU based on the location info

    CSV example:

    Name location
    JSMITH   US
    MGATES  EU
    JLEE       AP

    If location is US move user to OU=US,DC=test,DC=com
    If location is EU move user to OU=EU,DC=test,DC=com
    If location is AP move user to OU=AP,DC=test,DC-=com

    any suggestions?

    Thanks,

    Friday, April 26, 2019 9:37 PM

All replies

  • any suggestions?

    Either start to learn the very basics of Powershell or simply search for it on the internet. There are literally thousands of examples of something like this even here in this forum.

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Friday, April 26, 2019 10:13 PM
  • Hi,

    Thanks for your question.

    Please refer the link below:

    https://stackoverflow.com/questions/12712852/how-can-i-use-powershell-to-move-a-user-in-ad

    For example:

    $users=Import-Csv c:\temp\test.csv
    foreach($user in $users)
    {
      Get-ADUser -Identity $user.name | Move-ADObject -TargetPath "OU=$($user.Location),dc=test,dc=com"
    }

    Best regards,

    Lee


    Just do it.

    Tuesday, April 30, 2019 6:35 AM