add domain groups to vSphere ESXi 5 with PowerCLI

With PowerCLI, you can add AD authentication to a single managed ESXi Host. For this you need to add your ESXi-Host to the AD (line 9) and then add permissions (line 11):

$VMHost        = "hostname.domain.local"
$HostPW        = "yxz"
$DomainAdmin   = "DomainAdmin"
$DomainPW      = "yxz"
$ADGroup       = "domain\DomainGroup"
$Domain        = "domain.local"

Add-PSSnapin VMware.VimAutomation.Core

Connect-VIServer $VMHost –User root –Password $HostPW
Get-VMHostAuthentication -VMHost $VMHost | Set-VMHostAuthentication -Domain $Domain -Username $DomainAdmin -Password $DomainPW -JoinDomain -Confirm:$false

Get-VMHost $VMHost | New-VIPermission -Principal $ADGroup -Role "Admin"

Disconnect-VIServer $VMHost -Confirm:$false

sometimes line 11 will fail, then you have to wait for domain replication and repeat it.