Add computer to OU

  1. 7 months ago

    I'm trying to figure out how to get CD to add a computer to a specific OU during the deploy process.
    Am I right in thinking it works like the computer name change procedure. ie. setup the unattend.xml then configuring a profile for that image?
    I have attached my unattend file as my issue might be with this xml file. (the extension shows txt but when I sysprep I rename it to xml)

    thanks for you help.

  2. I'd assume you just change this <MachineObjectOU>computers</MachineObjectOU> to whatever OU.
    I personally use a powershell script that runs after setup.

  3. Seems to be a known issue:

    https://social.technet.microsoft.com/Forums/lync/en-US/b8917132-8e48-4bcd-a965-f6a64ac86ab8/sysprep-unattended-domain-join-adds-computer-but-uses-different-name-in-the-ou?forum=w7itproinstall

    as Dustin suggest best solution is to use powershell:

    http://powershellblogger.com/2015/10/join-computer-to-domain-with-desired-computer-name-and-ou/

  4. I second the powershell script.

  5. Ok, I have embraced the power shell idea and have found a script that works when I run it on the computer to be added to the domain. But it doesn't work when it's processed via a deploy in CD.
    Here is the scrip that I'm using

    $cred = New-Object System.Management.Automation.PsCredential("domain\useraccountwithjoinpermissions", (ConvertTo-SecureString "useraccountpassword" -AsPlainText -Force))
    Add-Computer -DomainName "your.domain.here" -Credential $cred -OUPath "OU=computers,OU=yourlocation,DC=your,DC=domain,DC=here"
    Restart-Computer

    And it's setup as follows.
    Computers, Computername I pick image profile of default
    in Images, "image name" Profile, Default scripts I have a scrip item with the above content modified for my environment.

    As I said the PS script works if I manually run it on my test machine but when I deploy to that same computer it doesn't add the computer to my domain.
    Is there something I'm missing?

    thanks for any help you can offer.

  6. clonedeploy

    15 Feb 2018 Administrator

    They were referring to running the script after imaging as more of setupcomplete type of thing. This won't work using CloneDeploy scripts since they run during imaging, you need something to run after imaging, but I think everyone is making this too complicated. I believe @vbourke does something like this.

    All you need to do is create a sysprep tag in CloneDeploy with the opening tag:
    <MachineObjectOU>
    and closing tag
    </MachineObjectOU>

    In the tag contents you put in the ou you want like:
    OU=laptops,OU=mybuilding,DC=mydomain,DC=com

    Or you can use custom attributes
    OU=$cust_attr_1,OU=$cust_attr_2,DC=mydomain,DC=com

    Assign the sysprep tags to the image profile.
    As long as your sysprep answer file has the MachineObjectOU tag somewhere in it, CloneDeploy will update it with the appropriate information based on the image profile, and sysprep will take of the rest.

  7. I must have read the first post to my request as the only way it could be done.
    Thanks for setting me on the easy path. I'll try this again

    K

 

or Sign Up to reply!