locked
Move Computers Automatically to respective OUs RRS feed

  • Question

  • Hi

    In my company we are using same name for both computer and user. However recently we have added a dot between first name and last name in user name because of the huge volume. As an example Michael.strauss. same change we have done in computer object also. Since computer name would not allow dot we put _ (underscore) like michael_strauss.

    We have default OU for putting all computer objects. but all users lies in separate OUs based on the department. Later we will move the computer objects manually to respective OUs

    Lets come to my requirement. We have an OU named HR. Under this we have HR login accounts which contains users and HR Computer accounts which contains computer objects. We need a script to automate this process. If we are adding a computer in domain first it will go to default OU, but once the script runs it should move the concerned OU based on the user name match. Two criterias. If the computer name is same as user name or the computer object has underscore for the dot which included in user objects.

    Could someone help me to create the script for this. I tried a lot. But this dot and underscore really giving me struggle.





    Shanif Salim

    Saturday, February 6, 2016 4:54 PM

Answers

  • Join computer to domain and move to correct OU.

    Add-Computer -DomainName Domain02 -OUPath 'OU=testOU,DC=domain,DC=Domain,DC=com'


    \_(ツ)_/

    • Proposed as answer by Yan Li_ Friday, February 12, 2016 7:14 AM
    • Marked as answer by Yan Li_ Tuesday, February 23, 2016 4:37 AM
    Tuesday, February 9, 2016 5:49 AM

All replies

  • You should not use underscores in computer names.  As you can see it lead to issues.

    You can use Move-AdObject to move the computers.

    Look in Gallery for example scripts: https://gallery.technet.microsoft.com/


    \_(ツ)_/

    Saturday, February 6, 2016 5:07 PM
  • Here are the rules for computer names. Notice the the underscore is specifically disallowed.

    https://support.microsoft.com/en-us/kb/909264


    \_(ツ)_/

    Saturday, February 6, 2016 5:09 PM
  • Yes, we can use this powershell cmdlet. But is it possible to automate this process according to our environment.

    Shanif Salim

    Monday, February 8, 2016 5:09 AM
  • Yes, we can use this powershell cmdlet. But is it possible to automate this process according to our environment.

    Shanif Salim


    Yes. Just run the command after you join the computer.

    \_(ツ)_/

    Monday, February 8, 2016 5:15 AM
  • Hi jrv

    This is a manual process. If we can automate this, it would be very helpful.

    Shanif Salim

    Tuesday, February 9, 2016 3:33 AM
  • But joining thee computer is a manual process.

    When you join a computer it can be targeted at an OU. Why is that not how you want to do this?


    \_(ツ)_/

    Tuesday, February 9, 2016 3:39 AM
  • I understand joining is a manual process. And based on our configuration all newly joined computers will go to our default OU. But after that the computer should move to respective OU automatically as i explained in my first question. Can it be automated

    We have slight difference between user name and computer name. If we can write it on powershell, i think we can accomplish this. But i am not much expert in powershell.


    Shanif Salim

    Tuesday, February 9, 2016 4:44 AM
  • Join computer to domain and move to correct OU.

    Add-Computer -DomainName Domain02 -OUPath 'OU=testOU,DC=domain,DC=Domain,DC=com'


    \_(ツ)_/

    • Proposed as answer by Yan Li_ Friday, February 12, 2016 7:14 AM
    • Marked as answer by Yan Li_ Tuesday, February 23, 2016 4:37 AM
    Tuesday, February 9, 2016 5:49 AM