Powershell – Add host to Cluster and license it.

By | June 13, 2010

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.

One thought on “Powershell – Add host to Cluster and license it.

  1. Pingback: Automated Cisco UCS Server Provisioning part 2 (the meat!) @ IT is what IT is

Leave a Reply

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