Hi,
Today, I want to configure an ESXi host to join a domain and set up Active Directory groups for logging in to ESXi using domain accounts, all through PowerShell.
Steps:
Run PowerShell as Administrator.
Install VMware PowerCLI by running the following command:
Install-Module VMware.PowerCLI
3. Connect to vCenter by running the following command:
Connect-VIServer -Server -user
Replace <vCenter-Server-IP-or-FQDN>
with the IP address or FQDN of your vCenter server.
4. Enter your vCenter username and password when prompted.
5. Create a variable to store the ESXi host object. For example:
$ESXiHost = Get-VMHost
6. Join the ESXi host to the domain using the following command:
$ESXiHost | Get-VMHostAuthentication | Set-VMHostAuthentication -JoinDomain
"DomainName" -user "Username" -password "password" -Confirm:$false
Replace:
<Domain-Name>
with your Active Directory domain name.<Domain-Admin-User>
with the username of a domain administrator.<Domain-Admin-Password>
with the corresponding password.
7- Add your Active Directory Group that member’s of that group want to 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 vmwaredaily.com -user vmwaredaily -password ******* -Confirm:$false
$ESXiHost | Get-AdvancedSetting -Name Config.HostAgent.plugins.hostsvc.esxAdminsGroup | Set-AdvancedSetting -Value vmwaredailyteam
Now, I have a username that is a member of vmwaredailyteam, I can log in with it to ESXi UI.
Finish