I just used the sample code to specify an OU with a space in it (two spaces in fact):
And the join completed to the requested OU. If you look at the file C:\Windows\Panther\unattend.xml on the deployed machine, do you see the expected value in the Identification MachineObjectOU definition of the unattend file? I did my testing with Windows Server 2022, so if you don't see that unattend file, check the logs under C:\windows\temp\vmware-imc, thats what pointed me to the panther directory.
Original Message:
Sent: May 12, 2025 09:47 PM
From: ScriptTheWorld
Subject: Join VM to Domain in specific OU
p0werShelldude -- The OU this explanation helped me as well, but the OU I'm dealing with has spaces in them (I know, spaces are bad), and although the code seems to function, the VMs don't join the OU. Have you seen this behavior, with regard to spaces?
Original Message:
Sent: Apr 22, 2025 11:52 AM
From: p0werShelldude
Subject: Join VM to Domain in specific OU
I'm using vCenter 8.0.3 Build: 24322831 with PowerCLI 13.3.0 Build 24145081. I was able to confirm that PowerCLI version 12.5.X it does not display the DomainOU property, but in version 13.3.X it does. Are you able to upgrade your PowerCLI and try again?
Original Message:
Sent: Apr 21, 2025 02:38 PM
From: M.S
Subject: Join VM to Domain in specific OU
Hi p0werShelldude,
this is exactly what I was looking for. But it is not working in my environment, cause the $specItem.Spec.Identity.Identification does not contain a DomainOU Property.
With which vCenter Version did you get this working? My is 8.0.3.
Original Message:
Sent: Apr 17, 2025 10:53 AM
From: p0werShelldude
Subject: Join VM to Domain in specific OU
I know the thread is over a year old, but for the next person needing to set a custom OU path, here's a simple way without needing to dive down the API route.
$osCustSpecName = 'OS Specification Name'
$organizationalUnit = 'OU=PathToOU,DC=Domain,DC=COM'
$osCustSpec = Get-View CustomizationSpecManager$specItem = $osCustSpec.GetCustomizationSpec($osCustSpecName)
$specItem.Spec.Identity.Identification.DomainOU = $organizationalUnit
$osCustSpec.OverwriteCustomizationSpec($specItem)
Original Message:
Sent: Oct 25, 2023 07:38 AM
From: Nasher_nathes
Subject: Join VM to Domain in specific OU
Good day.
In powerCLI i want create new VM, and use "New-OSCustomizationSpec -Type NonPersistent" with join to domain.
Has OSCustomizationSpec a parameter indicating a specific OU?
It is necessary that when entering the domain, the server is created in the required OU
Thank you.