Thanks, but unfortunately that suffers from the same problem: where there are multiple vCenters, it can't match a vCenter to its key. Here's the output of "$vSphereLicInfo | ?{$_.Product -like 'vCenter*'}" in my environment, for example (again, keys redacted):
vCenter Server : vc1
Product : vCenter Server 7 Standard
License Key : [key 1]
Capacity : 1
Usage : 1
Information :
Expiration Date : Never
vCenter Server : vc1
Product : vCenter Server 7 Standard
License Key : [key 2]
Capacity : 1
Usage : 1
Information :
Expiration Date : Never
"vCenter Server" is being populated by "([URI]$LicenseMan.Client.ServiceUrl).Host", but that's just the name of the vCenter that's accessing the License Manager, so it will always be the same for each entry. It has no connection to any particular vCenter key.
Original Message:
Sent: Feb 06, 2025 02:22 AM
From: Matthias Kaufmann
Subject: Is it possible to use PowerCLI to get the license keys for vCenters in linked mode?
have a look at this: vCheck-vSphere/Plugins/10 vCenter/82 License Report.ps1 at master · alanrenouf/vCheck-vSphere · GitHub
this lists the vCenter Server name using ([URI]$LicenseMan.Client.ServiceUrl).Host
Original Message:
Sent: Feb 05, 2025 07:17 PM
From: Matt Goddard
Subject: Is it possible to use PowerCLI to get the license keys for vCenters in linked mode?
I know how to use 'Get-View' to access the license manager and pull the license key for the vCenter I'm connected to. However, the output doesn't contain the vCenter name, so that method only works for a standalone instance; if it's a vCenter in linked mode, I can't match the keys to their vCenters.
A snippet of what I'm currently using:
$serviceInstance = Get-View -Server $myVcenter ServiceInstance
$licMgr = Get-View $serviceInstance.Content.LicenseManager
$licVcenter = $licMgr.Licenses | ?{$_.Name -like "*vcenter*"} | Sort Name,LicenseKey
Here's an example output of "$licVcenter | fl *" with two vCenters in linked mode (keys redacted, obviously):
LicenseKey : [key]
EditionKey : vc.standard.instance
Name : vCenter Server 7 Standard
Total : 1
Used : 1
CostUnit : server
Properties : {LicenseInfo, ProductName, ProductVersion, FileVersion...}
Labels :
LicenseKey : [key]
EditionKey : vc.standard.instance
Name : vCenter Server 7 Standard
Total : 1
Used : 1
CostUnit : server
Properties : {LicenseInfo, ProductName, ProductVersion, FileVersion...}
Digging into "Properties", I can't find anything that shows the vCenter name.
Is there another way to do this, perhaps?