VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot

ESXi License Expiration shows blank

Hi,

I am unable to get the ESXi License Expiration details from the below script. we have few servers with evaluation license and I am unable to get the expiration details.

Please help!!

$LicenseManager= Get-view LicenseManager
$LicenseAssignmentManager= Get-View $LicenseManager.LicenseAssignmentManager
Get-View -ViewType HostSystem |
select Name,
@{N='Cluster';E={
$parent = Get-View -Id $_.Parent -Property Name,Parent
While ($parent -isnot [VMware.Vim.ClusterComputeResource] -and $parent.Parent){
$parent = Get-View -Id $parent.Parent -Property Name,Parent
}
if($parent -is [VMware.Vim.ClusterComputeResource]){
$parent.Name}}},
@{N="Type";E={$_.Hardware.SystemInfo.Vendor+ " " + $_.Hardware.SystemInfo.Model}},
@{N="BIOS version"; E={$_.Hardware.BiosInfo.BiosVersion}},
@{N="BIOS date";E={$_.Hardware.BiosInfo.releaseDate}},
@{N='Product';E={$_.Config.Product.FullName}},
@{N='Build';E={$_.Config.Product.Build}},
@{N='LicenseType';E={
$script:licInfo = $LicenseAssignmentManager.GetType().GetMethod("QueryAssignedLicenses").Invoke($LicenseAssignmentManager,@($_.MoRef.Value))
$Script:licInfo.AssignedLicense.Name
}},
@{N='LicenseExpiration';E={
$lic = $LicenseManager.Licenses | where{$_.LicenseKey -eq $script:licInfo.assignedlicense.Licensekey}
$lic.Properties.GetEnumerator() | where{$_.Key -eq 'expirationDate'} | select -ExpandProperty Value}} |
Export-Csv -NoTypeInformation -Path ".\ESXi_License_Info.csv"

0 Kudos
6 Replies
LucD
Leadership
Leadership

Evaluation expiration dates are not stored under $LicenseManager.Licenses, but under $LicenseManager.Evaluation.
I don't have any of those, so I can check how to extract the expiration date.

You could check what is under $LicenseManager.Evaluation

$LicenseManager.Evaluation | Format-Custom


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot

LucD,

I am getting the output as below

class LicenseManagerEvaluationInfo
{
Properties =
[
class KeyAnyValue
{
Key = expirationHours
Value = 0
}
class KeyAnyValue
{
Key = expirationMinutes
Value = 0
}
class KeyAnyValue
{
Key = expirationDate
Value =
class DateTime
{
Date =
class DateTime
{
Date =
class DateTime
{
Date = 01/01/1970 12:00:00 AM
Day = 1
DayOfWeek = Thursday
DayOfYear = 1
Hour = 0
Kind = Utc
Millisecond = 0
Minute = 0
Month = 1
Second = 0
Ticks = 621355968000000000
TimeOfDay = 00:00:00
Year = 1970
DateTime = Thursday, January 1, 1970 12:00:00 AM
}
Day = 1
DayOfWeek = Thursday
DayOfYear = 1
Hour = 0
Kind = Utc
Millisecond = 0
Minute = 0
Month = 1
Second = 0
Ticks = 621355968000000000
TimeOfDay =
class TimeSpan
{
Ticks = 0
Days = 0
Hours = 0
Milliseconds = 0
Minutes = 0
Seconds = 0
TotalDays = 0
TotalHours = 0
TotalMilliseconds = 0
TotalMinutes = 0
TotalSeconds = 0
}
Year = 1970
DateTime = Thursday, January 1, 1970 12:00:00 AM
}
Day = 1
DayOfWeek = Thursday
DayOfYear = 1
Hour = 0
Kind = Utc
Millisecond = 0
Minute = 0
Month = 1
Second = 0
Ticks = 621355968000000000
TimeOfDay =
class TimeSpan
{
Ticks = 0
Days = 0
Hours = 0
Milliseconds = 0
Minutes = 0
Seconds = 0
TotalDays = 0
TotalHours = 0
TotalMilliseconds = 0
TotalMinutes = 0
TotalSeconds = 0
}
Year = 1970
DateTime = Thursday, January 1, 1970 12:00:00 AM
}
}
]

}

 

 

Tags (1)
0 Kudos
LucD
Leadership
Leadership

Besides the epoch date, there doesn't seem to be anything in there that is linked to licenses.
Sorry, can't help


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot

LucD,

Using the below command, I can get the license info from ESXi CLI, is there a way to pull through PowerCLI ?

vim-cmd vimsvc/license --show

[root@myesx20:~] vim-cmd vimsvc/license --show
[200] Sending request for installed licenses...[200] Complete, result is:
serial: 00000-00000-00000-00000-00000
vmodl key: eval
name: Evaluation Mode
total: 1
used: 1
unit: host
Properties:
[ProductName] = VMware ESX Server
[ProductVersion] = 6.0
[evaluation] = License has not been set, evaluation Period in effect.
[expirationHours] = 1440
[expirationMinutes] = 0
[expirationDate] = 2021-12-19T15:05:00.293202Z
[system_time] = 2021-10-20T15:05:00.297526Z
[feature] = vsmp:0 ("Unlimited virtual SMP")
[feature] = h264remote ("H.264 for Remote Console Connections")
[feature] = esxHost ("vCenter agent for VMware host")
[feature] = vimapi ("vSphere API")

0 Kudos
LucD
Leadership
Leadership

Afaik, there is no public API, and hence no option via PowerCLI, to do the same as that vim-cmd command is doing.


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot

np LucD, Thanks a lot for your help 🙂

 

0 Kudos