I received request from my internal team to provide a small solution on Esxi Domain join and created when pulled it in domain computer account should be created in specific OU (Organization Unit). To perform this task first, we need complete OU path, to find it open Active Directory Users and Computers, on the View menu click Advanced Features. For more on be
POWERCLI AND VSPHERE WEB CLIENT: JOIN ESXI INTO ACTIVE DIRECTORY DOMAIN CONTROLLER
Resolved: Esxi Join domain failed-Error in Active Directory Operations
Next click on the OU where you want to create Esxi Computer Account. Right click on OU and go to properties, You will see an Object tab, (This Object tab is only visible when Advanced features is enabled), Under it find Canonical name of object and copy paste OU path.
On the ESXi server when you try ESXi Join Domain under Authentication services. Use the path in Domain. Once esxi is joined to domain successfully, you will see new Esxi host computer account is created in active directory dsa.msc. If you are seeing an issue check my below article.
Resolved: Esxi Join domain failed-Error in Active Directory Operations
Next Same task I will perform using Active directory Powershell plug in and VMware vSphere Powercli. First to get OU canonical name running below command. Installing, importing and using any module in powershell
Get-ADOrganizationalUnit -Filter {Name -eq 'ESXi'} -Properties Canonicalname | Select CanonicalName
On the vSphere Powercli execute below command, This joins multiple Esxi server to AD domain at once to selected OU.
Get-VMHostAuthentication | Set-VMHostAuthentication -Domain 'vcloud-lab.com/Demo/ESXi' -JoinDomain -Username '[email protected]' -Password 'Computer@1' -Confirm:$false
POWERCLI INITIALIZE-POWERCLI ENVIRONMENT.PS1 CANNOT BE LOADED BECAUSE RUNNING SCRIPTS IS DISABLED
VMWARE VSPHERE POWERCLI INSTALLATION AND CONFIGURATION STEP BY STEP
If there are no errors on PowerCLI while executing commands, Computer Accounts are created successfully and same can be verified using below one liner cmdlet.
Get-ADComputer -SearchBase 'OU=ESXi,OU=Demo,DC=vcloud-lab,DC=com' -Filter *
Useful Blogs
VMWare Powercli: Time Configuration (NTP - Network Time Protocol) on multiple Esxi server
vSphere PowerCLI - Configure syslog on VMware ESXi hosts and Enable security profile firewall