How to Retrieve vSAN License Key from an ESXi Cluster using PowerCLI

vSAN is a software-defined storage solution from VMware that is integrated with the vSphere platform. To use vSAN, you need to have a valid license key assigned to your ESXi hosts. In this blog post, we’ll show you how to retrieve the vSAN license key from an ESXi cluster using PowerCLI.


#Assuming already established connection to your VCSA.

$clust = Read-Host "Enter Cluster Name: "
$cluster = Get-Cluster $clust 

$serviceinstance = Get-View ServiceInstance
$LicManRef=$serviceinstance.Content.LicenseManager
$LicManView=Get-View $LicManRef
$licenseassetmanager = Get-View $LicManView.LicenseAssignmentManager
$script:licInfo = $licenseassetmanager.GetType().GetMethod("QueryAssignedLicenses").Invoke($licenseassetmanager,@($dd1.MoRef.Value))
$lkey = $licInfo.assignedlicense.LicenseKey 


foreach ($obj in $licInfo){
    if ($obj.EntityDisplayName -eq $cluster){
    $key = $obj.assignedlicense.LicenseKey
    Write-Host "$cluster has vSAN $key"
    }