This PowerShell script adds a host to a Cluster and licenses it.


Add-PSSnapin VMware.VimAutomation.Core
Connect-VIServer "VC_server_name" -User "Administrator" -Password "password"
add-vmhost "esxhost" -location (get-datacenter -name 'Datacenter' | 
   get-folder -name 'Folder' | get-cluster -name 'Cluster') -user "root" 
   -password "password" -force: $true
$targethostMoRef = (get-VMHost $strHost  | get-view).MoRef
$si = Get-View ServiceInstance
$LicManRef=$si.Content.LicenseManager
$LicManView=Get-View $LicManRef
$licassman = Get-View $LicManView.LicenseAssignmentManager
$licassman.UpdateAssignedLicense($targethostMoRef.value,”YOUR LIC KEY”,
   ”vSphere4 Enterprise Plus (1-12 cores per CPU”)
Disconnect-VIServer -Confirm:$false

Download it here.