How to join ESXi to the domain and set Active Directory groups to log in to ESXi via PowerShell.

Hi, Today I want to set the ESXi host to join to the domain and I adjust Active Directory groups to log in to ESXi with domain’s account, through PowerShell.

1- Run PowerShell as Administrator

2- Install VMware powercli

Install-Module VMware.PowerCLI

3- Connect to vCenter

Connect-VIServer -Server "your Server FQDN or IP address" -user "your username"

4- Enter your vCenter username and password

5- Create a variable

$ESXiHost = Get-VMHost

6- Join to Domain

$ESXiHost | Get-VMHostAuthentication | Set-VMHostAuthentication -JoinDomain 
"DomainName" -user "Username" -password "password" -Confirm:$false

7- Add your Active Directory Group that member’s of that group want login to ESXi Host.

$ESXiHost | Get-AdvancedSetting -Name Config.HostAgent.plugins.hostsvc.esxAdminsGroup | Set-AdvancedSetting -Value "Group Name"

For Example:

Connect-VIServer -Server vcenter.khoshraftar.com -User administrator@vsphere.local

$ESXiHost = Get-VMHost

$ESXiHost | Get-VMHostAuthentication | Set-VMHostAuthentication -JoinDomain -Domain khoshraftar.com -user khoshraftar -password *******  -Confirm:$false

$ESXiHost | Get-AdvancedSetting -Name Config.HostAgent.plugins.hostsvc.esxAdminsGroup | Set-AdvancedSetting -Value  VirtualizationTeam  

Now, I have a username that is a member of VirtualizationTeam, I can login with it to ESXi UI.

Finish 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *