I made a script that will output the current license keys per cluster and changes them to a new one which the script will ask for. Just make sure you have the license key already added to vCenter. The script will ask you for inputs so it should just work. But better to be safe then sorry and test it first!

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
$vcenter = [Microsoft.VisualBasic.Interaction]::InputBox('Enter vCenter Name...', 'vCenter Name')
Connect-VIServer $vcenter

$cluster = Get-Cluster | Out-GridView -OutputMode Single -Title "Select Cluster"
$hosts = Get-Cluster $cluster | Get-VMHost | Sort-Object

foreach ($esxhost in $hosts){
    $currentkey = Get-VMHost $esxhost | Select LicenseKey
    Write-Host $esxhost License key is currently: $currentkey.LicenseKey -ForegroundColor Green

$newlicensekey = [Microsoft.VisualBasic.Interaction]::InputBox('New License Key', 'License Key')

foreach ($esxhost in $hosts){
    Set-VMHost -VMHost $esxhost -LicenseKey $newlicensekey
    Write-Host $esxhost License key set to $esxhost.LicenseKey -ForegroundColor Green

Disconnect-VIServer * -Confirm:$false

The original article was posted on: www.hollebollevsan.nl

Related articles

  • Cloud Native
  • Implementation and Adoption
  • Platform Engineering
  • Digital Workspace
  • Hybrid Cloud
  • ITTS (IT Transformation Services)
  • Managed Security Operations
  • Managed Cloud Platform
  • Backup & Disaster Recovery
Visit our knowledge hub
Visit our knowledge hub
Paul van Dieën Virtualization Consultant

Let's talk!

Knowledge is key for our existence. This knowledge we use for disruptive innovation and changing organizations. Are you ready for change?

"*" indicates required fields

First name*
Last name*