Join VM to specific Active Directory OU using System Center VMM 2012 Guest OS Profile
We use System Center 2012 Virtual Machine Manager to deploy VMs to our Hyper-V servers. We are starting to use the VM and Service templates to automate our system deployments, but one step we need to automate is adding the server to our Active Directory domain under a specific Organizational Unit. I am able to create a Guest OS Profile that uses a Run As account to join the server to the domain, but there is no option for specifying the OU:
How can I specify the OU to use when joining the domain?
Solution 1:
It appears there are two ways to specify an OU when joining a VM to the domain using a Guest OS Profile. The first is to use the Get-SCGuestOSProfile and Set-SCGuestOSProfile PowerShell cmdlets to modify the DomainJoinOrganizationalUnit setting used to join the domain. This is the most straight forward approach but is not visible in the GUI and is a bit more difficult to setup.
The second is to add an unattend.xml file to your VMM Library that includes the the MachineObjectOU element. In my case I used the following to join a 2012 Server to the "My Servers" OU on our Child.Parent.com domain:
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="specialize">
<component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<Identification>
<MachineObjectOU>OU=My Servers,DC=Child,DC=Parent,DC=com</MachineObjectOU>
</Identification>
</component>
</settings>
</unattend>
The unattend.xml file will be merged with the settings provided in the Guest OS profile (like the domain join credentials), so this option will also let you customize other installation settings and will still visible in the GUI.