ESXi veya vCenter sunucuları gibi VMware vSphere bileşenleri için lisans atamak ve güncellemek kimsenin dört gözle beklediği bir şey değildir ve şimdiye kadar kapsamlı bir altyapıyı yönetmekle uğraşan her yöneticinin aynı fikirde olacağını düşünüyorum.
Bu nedenle, PowerCLI ile sürecin ne kadar hızlı ve basit olduğu etkileyici görünebilir.
set vCenter credentials
$vCenter = “FQDN of your vCenter”
$User= “Username”
$Password= “Password unmasked”
$License = “License Key”
## Convert the password to connect
$EncryptedPassword = ConvertTo-SecureString -String “$Password” -AsPlainText -Force
## Set the credentials or you can alternatively request them using the interactive mode with $Credential = get-credential
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $EncryptedPassword
#Connect to the vCenter
Disconnect-VIServer -confirm:$false -ErrorAction SilentlyContinue
Write-Host “Now connecting to $vCenterServer”
$vCenter = Connect-VIServer -Server $vCenterServer -Credential $Credential
## Assign/update license key for this particular vCenter:
$LM = get-view($vCenter.ExtensionData.content.LicenseManager)
$LM.AddLicense($License,$null)
$LAM = get-view($LicenseManager.licenseAssignmentManager)
$LAM.UpdateAssignedLicense($vCenter.InstanceUuid,$License,$Null)
Ayrıca atamak veya güncellemek için daha fazla anahtarınız varsa bu senaryoyu biraz değiştirebilirsiniz:
$licenses = “key1″,”key2,”key3″,”key4”
## Adding more licenses to the existing licenses
$LicenseManager = get-view ($vc.ExtensionData.content.LicenseManager)
$existinglicenses = $LicenseManager.licenses.licensekey
$licensestoadd = $licenses | where-object {$_ -notin $existinglicenses}
foreach ($license in $licensestoadd)
{
write-host”Adding license”+$license
$LicenseManager.AddLicense($license,$null)
}
## Create the keys for vCenter version
$majorversion = $vc.version.split(“.”)[0]
$vcenterlicense = ($LicenseManager.licenses | where {$_.name -like “*vCenter*” -and $_.name -like “*$majorversion*”} | select -first 1).licensekey
## Update license for this particular vCenter instance:
$LicenseAssignmentManager = get-view ($LicenseManager.licenseAssignmentManager)
$LicenseAssignmentManager.UpdateAssignedLicense($vCenter.InstanceUuid,$vcenterlicense,$Nul)
$licenses = “key1″,”key2,”key3″,”key4”
## Adding more licenses to the existing licenses
$LicenseManager = get-view ($vc.ExtensionData.content.LicenseManager)
$existinglicenses = $LicenseManager.licenses.licensekey
$licensestoadd = $licenses | where-object {$_ -notin $existinglicenses}
foreach ($license in $licensestoadd)
{
write-host”Adding license”+$license
$LicenseManager.AddLicense($license,$null)
}
## Create the keys for vCenter version
$majorversion = $vc.version.split(“.”)[0]
$vcenterlicense = ($LicenseManager.licenses | where {$_.name -like “*vCenter*” -and $_.name -like “*$majorversion*”} | select -first 1).licensekey
## Update license for this particular vCenter instance:
$LicenseAssignmentManager = get-view ($LicenseManager.licenseAssignmentManager)
$LicenseAssignmentManager.UpdateAssignedLicense($vCenter.InstanceUuid,$vcenterlicense,$Nul)
VMware ESXi lisansını eklemek/güncellemek isterseniz bir yol daha vardır.
## Find host by name
$vmhost = Get-VMHost -Name Host
## Add a license key to it
Set-VMHost -VMHost $vmhost -LicenseKey YXXXXX-XXXXX-XXXXX-XXXXX-XXXXX
## Find host by name
$vmhost = Get-VMHost -Name Host
## Add a license key to it
Set-VMHost -VMHost $vmhost -LicenseKey YXXXXX-XXXXX-XXXXX-XXXXX-XXXXX
Cluster’daki tüm esxi’lar yalnızca VMware ESXi lisans anahtarını eklemek istiyorsanız;
get-cluster ClusterName | get-vmhost | set-vmhost -LicenseKey XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
1
get-cluster ClusterName | get-vmhost | set-vmhost -LicenseKey XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
ESXi için anahtar eklemek için 00000-00000-00000-00000-00000 olarak yazmanız yeterlidir.
Mevcut lisans anahtarlarını kontrol etmek istiyorsanız iseniz;
Get-VMHost | Select Name, LicenseKey
Get-VMHost | Select Name, LicenseKey