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
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
$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

  • Hybrid Cloud
  • Cloud Native
  • Dev Enablement
  • Platform Engineering
  • Implementation and Adoption
  • Digital Workspace
  • Application Management Services
  • Data Center Modernization
  • Managed Cloud Platform
  • Public Cloud Landing Zones
  • Sovereign Cloud
Visit our knowledge hub
Visit our knowledge hub
Paul van Dieën IT 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*
This field is hidden when viewing the form