There are a couple of ways in which you can assign license keys to hosts that you can provisioned with Auto Deploy. You can use the traditional method of assigning licenses using vCenter, or you can use PowerCLI to add a pre-defined set of license keys to the vCenter database. When a host is connected to vCenter it will automatically be assigned a license.
The process using PowerCLI is as follows:
1. Connect to vCenter:
Connect-VIServer -Server vCenterAddress -User username -Password password
2. Point at the license server and datacenter for bulk licensing:
$licenseDataManager = Get-LicenseDataManager
$hostContainer = Get-DataCenter -Name DataCenterName
3. Add a new license:
$licenseData = New-Object VMware.VimAutomation.License.Types.LicenseDate
$licenseKeyEntry = New-Object Vmware.VimAutomation.License.Types.LicenseKeyEntry
$licenseKeyEntry.TypeId = “vmware-vsphere”
$licenseKeyEntry.LicenseKey = “XXXXX-XXXXX-XXXXX-XXXXX-XXXXX”
$licenseData.LicenseKeys += $licenseKeyEntry
4. Update the License Data:
$licenseDataManager.UpdateAssociatedLicenseData($hostContainer.Uid, $licenseData)
$licenseDataManager.QueryAssociatedLicenseData($hostContainer.Uid)
Now, when your Auto Deploy provisioned hosts connect to vCenter, they should pick up a license automatically.