Hi all,
With the help of the community I was able to piece together a build script for ESXi 3.5 (basic/free edition). This script works fine with ESXi 4 (VSphere) but I am stuck on the section that completes the License Key install.
The orgional code segment for ESXi 3.5 was this:
$ESXHost=Get-VMHost
$ESXHostView=$ESXHost | Get-View
$ESXHostView
$ServiceInstance=Get-View -Server $ESXConnect ServiceInstance
$ServiceInstance.Content
$LicManRef=$ServiceInstance.Content.LicenseManager
$LicManView=Get-View -Server $ESXConnect $LicManRef
$LicServerSource=New-Object VMWARE.VIM.LocalLicenseSource
$LicServerSource.LicenseKeys="11111-AAAAA-BBBBB-CCCCC-DDDDD "
$LicManView.SetLicenseEdition($ESXHostView.MoRef,"")
$LicManView.ConfigureLicenseSource($ESXHostView.MoRef,$LicServerSource)
...but now the licensing system has changed we need to do something else. I have checked the new API v4.0 Reference and it has pointed me to where I can find the key but I dont know enough to get it to automatically assign.
Source :
SourceAvailable : False
Diagnostics :
FeatureInfo : {}
LicensedEdition :
Licenses : {ESXi 4 Single Server}
LicenseAssignmentManager :
Evaluation : VMware.Vim.LicenseManagerEvaluationInfo
MoRef : VMware.Vim.ManagedObjectReference
Client : VMware.Vim.VimClient
LicenseKey : 11111-AAAAA-BBBBB-CCCCC-DDDDD (my basic v4 key)
EditionKey : esxBasic
Name : ESXi 4 Single Server
Total : 0
Used : 1
CostUnit : cpuPackage:6core
Properties : {ProductName, ProductVersion, feature, feature...}
Labels :
DynamicType :
DynamicProperty :
Any help on this will be greatly appreciated
Thanks
Chris
Learn something new everyday!
$h = get-vmhost $hv = $h | get-view $si = Get-View ServiceInstance $LicManRef=$si.Content.LicenseManager $LicManView=Get-View $LicManRef $license = New-Object VMware.Vim.LicenseManagerLicenseInfo $license.LicenseKey = "YOUR LICENSE HERE" $license.EditionKey="esxBasic" $LicManView.UpdateLicense($license.LicenseKey,$null)
I think this might actually be simpler. There is a new AddLicense method on the LicenseManager that seems to take the license key as a parameter (licenseKey).
Try this:
$h = get-vmhost $hv = $h | get-view $svcRef = New-Object VMware.Vim.ManagedObjectReference $svcRef.Type = “ServiceInstance” $svcRef.Value = “ServiceInstance” $serviceInstance = Get-View $svcRef $LicManRef=$ServiceInstance.Content.LicenseManager $LicManView=Get-View $LicManRef $license = New-Object VMware.Vim.LicenseManagerLicenseInfo $license.LicenseKey = "YOUR LICENSE HERE" $license.EditionKey="esxBasic" $LicManView.UpdateLicense($license.LicenseKey,$null)
FYI you can just use
$si = Get-View ServiceInstance
Learn something new everyday!
$h = get-vmhost $hv = $h | get-view $si = Get-View ServiceInstance $LicManRef=$si.Content.LicenseManager $LicManView=Get-View $LicManRef $license = New-Object VMware.Vim.LicenseManagerLicenseInfo $license.LicenseKey = "YOUR LICENSE HERE" $license.EditionKey="esxBasic" $LicManView.UpdateLicense($license.LicenseKey,$null)
Wow thanks for the quick reply Doug. Works perfectly.