StuDuncanHPE
Enthusiast
Enthusiast

Licenses with & without linked vcenters

Follow on to my license question from yesterday. I'm getting all the licenses now, and its working well.

Except that for any linked vcenters, I get duplicates - one from each vcenter.

I've tried connecting with and without the '-AllLinked' option, but it doesn't make a difference.

 

Is there any way programmatically to get the license manager of linked vcenters to give me just one instance instead of two?

I'm looking at hashing all the keys as they're retrieved, and checking the new key against the hash, but that seems clunky.

I really don't want to have a linked listed and a separate an unlinked list.

0 Kudos
4 Replies
LucD
Leadership
Leadership

Did you use the Server parameter in 

$licMgr = Get-View LicenseManager -Server $_
$licAssignmentMgr = Get-View -Id $licMgr.LicenseAssignmentManager -Server $vc

Note that the script from the other thread looks at all vCenters (what is $global:defaultVIServers)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
StuDuncanHPE
Enthusiast
Enthusiast

No, I'm back to just using the LicenseManager since I can get used & total licenses.  But it still connects into each vcenter, and treats the linked ones as unique license mangers.  As you can see, the hashed keys are there, and works (except for one weird licensing issue on a single vcenter).  But seems like there should be a 'linked' license manager. I dunno, maybe I'm just dreaming.

 

 

foreach ($vc in $vcs){
    Connect-VIServer $vc -credential $cred -AllLinked
}

$vSphereLicInfo = @() 
$keyHash = @{}
$LicenseMan = Get-View LicenseManager 
    Foreach ($License in $LicenseMan.Licenses) { 
        $Details = "" |Select VC, Name, Key, Total, Used, ExpirationDate , Information
        if ( ($license.LicenseKey -ne "00000-00000-00000-00000-00000") -and !($keyHash[$License.LicenseKey]) ) {
            $Details.VC = ([Uri]$LicenseMan.Client.ServiceUrl).Host
            $Details.Name= $License.Name
            $Details.Key= $License.LicenseKey
            $Details.Used= $License.Used
            $Details.Total= $License.Total
            $Details.Information= $License.Labels | Select -expand Value
            $Details.ExpirationDate = $License.Properties | Where { $_.key -eq "expirationDate" } | Select -ExpandProperty Value
            $keyHash[$Details.Key] = $Details
            $vSphereLicInfo += $Details 
        }
    } 
 

$vSphereLicInfo  | Export-Csv ("D:\Reports\VMwareLicenseReport_" + (get-date -format yyyy-MM-ddTHH-mm-ss-ff) + ".csv") -NoTypeInformation

Disconnect-VIServer * -Confirm:$false

 

 

0 Kudos
LucD
Leadership
Leadership

Afaik, licenses are replicated between vCenters in Enhanced Linked Mode.
If that is your setup, you should only query 1 vCenter and it's LicenseManager


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

StuDuncanHPE
Enthusiast
Enthusiast

Appreciate the info. Was hoping it wasn't true, but makes sense.

0 Kudos