PowerShell script exchange
Post Reply
riahc3
Enthusiast
Posts: 89
Liked: 5 times
Joined: Oct 21, 2015 10:01 am
Full Name: John
Contact:

Check days left in license for Veeam 10?

Post by riahc3 » 1 person likes this post

Hello

I had this Powershell script for Veeam 9.x to check the days left in my license:

Code: Select all

$warn=45
$crit=15
$returnStateOK = 0
$returnStateWarning = 1
$returnStateCritical = 2
$returnStateUnknown = 3
$regBinary = (Get-Item 'HKLM:\SOFTWARE\VeeaM\Veeam Backup and Replication\license').GetValue('Lic1')
$veeamLicInfo = [string]::Join($null, ($regBinary | % { [char][int]$_; }))  
$ExpirationDateFormat = "Expiration date\=\d{1,2}\/\d{1,2}\/\d{1,4}"
$ExpirationDate = [regex]::matches($VeeamLicInfo, $ExpirationDateFormat)[0].Value.Split("=")[1]
$end= (Get-Date $ExpirationDate).tostring(“dd-MM-yyyy”)
$today=[datetime](Get-Date)
$daysleft=(NEW-TIMESPAN –Start $today –End $end).Days
if ( ($daysleft -gt $warn) -and  ($daysleft -gt $crit))
{
    Write-Host "OK: Veeam License Days Left: $daysleft|daysleft=$daysleft"
    exit $returnStateOK
}
elseIf ( ($daysleft -le $warn) -and ($daysleft -gt $crit)) 
{
    Write-Host "WARNING: Veeam License Days Left: $daysleft|daysleft=$daysleft"
    exit $returnStateWarning
}
elseIf ( ($daysleft -le $crit)) 
{
    Write-Host "CRITICAL: Veeam License Days Left: $daysleft|daysleft=$daysleft"
    exit $returnStateCritical
}
else
{
    Write-Host "UNKNOWN: Cannot get Veeam License information"
    exit $returnStateUnknown
}
But it seems that Veeam 10's license has changed so....


Could someone please tell me the new format on getting the days left in the license?

Thank you

veremin
Product Manager
Posts: 17834
Liked: 1661 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Check days left in license for Veeam 10?

Post by veremin » 3 people like this post

Use new cmdlet - Get-VBRInstalledLicense. The return object should contain information you're after. Thanks!

riahc3
Enthusiast
Posts: 89
Liked: 5 times
Joined: Oct 21, 2015 10:01 am
Full Name: John
Contact:

Re: Check days left in license for Veeam 10?

Post by riahc3 »

FINNALY! A cmdlet! Thank you very much for adding it...

Im redoing my script now :)

riahc3
Enthusiast
Posts: 89
Liked: 5 times
Joined: Oct 21, 2015 10:01 am
Full Name: John
Contact:

Re: Check days left in license for Veeam 10?

Post by riahc3 »

Get-VBRInstalledLicense : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Veeam\Veeam Backup and Replication' is denied.

I dont think that cmdlet should need admin rights to READ that. That registry key should be open to Everyone for READING purposes....

riahc3
Enthusiast
Posts: 89
Liked: 5 times
Joined: Oct 21, 2015 10:01 am
Full Name: John
Contact:

Re: Check days left in license for Veeam 10?

Post by riahc3 »

Also cmdlet is VERY slow

evilaedmin
Expert
Posts: 159
Liked: 24 times
Joined: Jul 26, 2018 8:04 pm
Full Name: Eugene V
Contact:

Re: Check days left in license for Veeam 10?

Post by evilaedmin »

riahc3 wrote: Feb 29, 2020 11:31 am Get-VBRInstalledLicense : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Veeam\Veeam Backup and Replication' is denied.

I dont think that cmdlet should need admin rights to READ that. That registry key should be open to Everyone for READING purposes....
You can use registry ACLs to do what you wish. A Read permission on a key and admin rights are completely separate (but related) topics. I can't say at all if this is supported or unsupported and you will need to think if it applies to your environment, but we give special users of Backup server read:

Image

oleg.feoktistov
Veeam Software
Posts: 499
Liked: 167 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Check days left in license for Veeam 10?

Post by oleg.feoktistov »

I dont think that cmdlet should need admin rights to READ that. That registry key should be open to Everyone for READING purposes....
It's a matter of permissions for a specific account, not for a specific cmdlet. Allowing that by default would also mean non-admin users could get other VBR infrastructure-related info
with VeeamPSSnapin cmdlets. But you can use the solution @evilaedmin mentioned.
Also cmdlet is VERY slow
Are you using remote VBR console? Just tested it in my lab and it resolved license information in a matter of seconds.

Thanks,
Oleg

veremin
Product Manager
Posts: 17834
Liked: 1661 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Check days left in license for Veeam 10?

Post by veremin »

riahc3 wrote: Feb 29, 2020 11:31 am Get-VBRInstalledLicense : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Veeam\Veeam Backup and Replication' is denied. I dont think that cmdlet should need admin rights to READ that. That registry key should be open to Everyone for READING purposes....
Try to run under admin account and see whether it makes a difference. Thanks!

mwiles
Influencer
Posts: 17
Liked: 3 times
Joined: Jun 12, 2019 9:00 pm
Full Name: Michael Wiles
Contact:

Re: Check days left in license for Veeam 10?

Post by mwiles »

I have not opened a case for this yet, but we are seeing an issue when we have list of VBRs (VBR-A & VBR-B)
If we try to retrieve the Veeam.Backup.PowerShell.Infos.VBRInstanceLicenseSummaryObject it will only come back non-null for one of the them.
If in a new/separate PS session for each server, it works fine.

I have pulled this snipped from the PS1 file ....

Code: Select all

$Servers = "VBR-A,VBR-B"
$Servers_Array = $Servers.split(",")
foreach($Server in $Servers_Array)  {
       Connect-VBRServer -Server $Server -User $User -Password $Pass
       $license = Get-VBRInstalledLicense
       $license_summary = $license.InstanceLicenseSummary
       $license_summary_details= $license_summary.Object      #<-----this is null sometimes
       Disconnect-VBRServer 
}
Any help would be appreciated.

mwiles
Influencer
Posts: 17
Liked: 3 times
Joined: Jun 12, 2019 9:00 pm
Full Name: Michael Wiles
Contact:

Re: Check days left in license for Veeam 10?

Post by mwiles »

typo above -- actually $license_summary is the null variable.

mwiles
Influencer
Posts: 17
Liked: 3 times
Joined: Jun 12, 2019 9:00 pm
Full Name: Michael Wiles
Contact:

Re: Check days left in license for Veeam 10?

Post by mwiles »

case 04213956 opened.

oleg.feoktistov
Veeam Software
Posts: 499
Liked: 167 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Check days left in license for Veeam 10?

Post by oleg.feoktistov »

if you write to a variable inside a loop, it always holds the latest value written. You need to create a variable with an empty array right before the loop and append $licence_summary_details to it each iteration. This variable will hold the array of license objects for each VBR server when all the iterations are done.
Thanks!

mwiles
Influencer
Posts: 17
Liked: 3 times
Joined: Jun 12, 2019 9:00 pm
Full Name: Michael Wiles
Contact:

Re: Check days left in license for Veeam 10?

Post by mwiles »

I did not share the entire script, but those variables are created outside of the loop. I think something is not clearing the connection / session. Not sure if additional information is helpful, but one VBR is licensed for Backup, the other is for CCR.
When I connect to the first server I get that license, never get one from the servers after. Disconnect-Server does not help. If I close the PowerShell IDE, restart, change the order of the servers ... I still only ever get the first one. Since there is no argument for Get-VBRInstalledLicense, I can only assume Connect/Disconnect is sufficient.

mwiles
Influencer
Posts: 17
Liked: 3 times
Joined: Jun 12, 2019 9:00 pm
Full Name: Michael Wiles
Contact:

Re: Check days left in license for Veeam 10?

Post by mwiles »

I do get much of the license information (e.g. Status, Exp Date, Type, Edition ... etc) from the primary VBRInstalledLicense object. I also get partial information (e.g.. License Instance Number, Used Instance Number, New Instance Number ... etc) from the InstanceLicenseSummary ... but the InstanceLicenseSummary.Object is null after the first connection to the server.

veremin
Product Manager
Posts: 17834
Liked: 1661 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Check days left in license for Veeam 10?

Post by veremin »

Do you have any workload already protected with instances? Thanks!

mwiles
Influencer
Posts: 17
Liked: 3 times
Joined: Jun 12, 2019 9:00 pm
Full Name: Michael Wiles
Contact:

Re: Check days left in license for Veeam 10?

Post by mwiles »

Yes workload already exists in backup server, but dont think VCCR works that way?

If I run a query for single server, restart powershell session, run other server ...

backupserver

Code: Select all

PS C:\Windows\system32> C:\Get-VBRLicenseUsage.ps1
backupserver
===========license===========
Status                              : Valid
ExpirationDate                      : 9/30/2020 12:00:00 AM
Type                                : Rental
Edition                             : EnterprisePlus
LicensedTo                          : REDACTED
SocketLicenseSummary                : {Veeam.Backup.PowerShell.Infos.VBRSocketLicenseSummary}
InstanceLicenseSummary              : Veeam.Backup.PowerShell.Infos.VBRInstanceLicenseSummary
CapacityLicenseSummary              : Veeam.Backup.PowerShell.Infos.VBRCapacityLicenseSummary
SupportId                           : 
SupportExpirationDate               : 
AutoUpdateEnabled                   : False
FreeAgentInstanceConsumptionEnabled : True
CloudConnect                        : Disabled
===========license_summary===========
LicensedInstancesNumber : 130000
UsedInstancesNumber     : 110
NewInstancesNumber      : 11
RentalInstancesNumber   : 0
Object                  : {Veeam.Backup.PowerShell.Infos.VBRInstanceLicenseSummaryObject}
Workload                : {Test-2-BxDK, Server-02-2FKV, AppVM1-mNJd, devbox-F4KC...}
===========license_summary_details===========
Type                : VM
Count               : 10
Multiplier          : 11
UsedInstancesNumber : 110
restart Powershell session and run for vccrserver

Code: Select all

PS C:\Windows\system32> C:\Get-VBRLicenseUsage.ps1
vccrserver
===========license===========
Status                              : Valid
ExpirationDate                      : 9/30/2020 12:00:00 AM
Type                                : Rental
Edition                             : EnterprisePlus
LicensedTo                          : REDACTED
SocketLicenseSummary                : {Veeam.Backup.PowerShell.Infos.VBRSocketLicenseSummary}
InstanceLicenseSummary              : Veeam.Backup.PowerShell.Infos.VBRInstanceLicenseSummary
CapacityLicenseSummary              : Veeam.Backup.PowerShell.Infos.VBRCapacityLicenseSummary
SupportId                           : 
SupportExpirationDate               : 
AutoUpdateEnabled                   : False
FreeAgentInstanceConsumptionEnabled : True
CloudConnect                        : Enabled
===========license_summary===========
LicensedInstancesNumber : 20000
UsedInstancesNumber     : 50
NewInstancesNumber      : 30
RentalInstancesNumber   : 0
Object                  : {Veeam.Backup.PowerShell.Infos.VBRInstanceLicenseSummaryObject}
Workload                : {}
===========license_summary_details===========
Type                : CloudConnectReplicationVM
Count               : 5
Multiplier          : 10
UsedInstancesNumber : 50
running them back to back ....

Code: Select all

PS C:\Windows\system32> C:\Get-VBRLicenseUsage.ps1
backupserver
===========license===========
Status                              : Valid
ExpirationDate                      : 9/30/2020 12:00:00 AM
Type                                : Rental
Edition                             : EnterprisePlus
LicensedTo                          : REDACTED
SocketLicenseSummary                : {Veeam.Backup.PowerShell.Infos.VBRSocketLicenseSummary}
InstanceLicenseSummary              : Veeam.Backup.PowerShell.Infos.VBRInstanceLicenseSummary
CapacityLicenseSummary              : Veeam.Backup.PowerShell.Infos.VBRCapacityLicenseSummary
SupportId                           : 
SupportExpirationDate               : 
AutoUpdateEnabled                   : False
FreeAgentInstanceConsumptionEnabled : True
CloudConnect                        : Disabled
===========license_summary===========
LicensedInstancesNumber : 130000
UsedInstancesNumber     : 110
NewInstancesNumber      : 11
RentalInstancesNumber   : 0
Object                  : {Veeam.Backup.PowerShell.Infos.VBRInstanceLicenseSummaryObject}
Workload                : {Test-2-BxDK, Server-02-2FKV, AppVM1-mNJd, devbox-F4KC...}
===========license_summary_details===========
Type                : VM
Count               : 10
Multiplier          : 11
UsedInstancesNumber : 110

vccrserver
===========license===========
Status                              : Valid
ExpirationDate                      : 9/30/2020 12:00:00 AM
Type                                : Rental
Edition                             : EnterprisePlus
LicensedTo                          : REDACTED
SocketLicenseSummary                : {Veeam.Backup.PowerShell.Infos.VBRSocketLicenseSummary}
InstanceLicenseSummary              : Veeam.Backup.PowerShell.Infos.VBRInstanceLicenseSummary
CapacityLicenseSummary              : Veeam.Backup.PowerShell.Infos.VBRCapacityLicenseSummary
SupportId                           : 
SupportExpirationDate               : 
AutoUpdateEnabled                   : False
FreeAgentInstanceConsumptionEnabled : True
CloudConnect                        : Enabled
===========license_summary===========
LicensedInstancesNumber : 20000
UsedInstancesNumber     : 0
NewInstancesNumber      : 0
RentalInstancesNumber   : 0
Object                  : {}
Workload                : {}
===========license_summary_details===========

veremin
Product Manager
Posts: 17834
Liked: 1661 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Check days left in license for Veeam 10?

Post by veremin »

Object is not null, it's an array of Veeam.Backup.PowerShell.Infos.VBRInstanceLicenseSummaryObject objects. To access it you can use "."

Code: Select all

$licensesummary.object
Thanks!

mwiles
Influencer
Posts: 17
Liked: 3 times
Joined: Jun 12, 2019 9:00 pm
Full Name: Michael Wiles
Contact:

Re: Check days left in license for Veeam 10?

Post by mwiles »

i believe Veeam support has reproduced my use case. Stay tuned

abarrett
Novice
Posts: 3
Liked: never
Joined: Nov 20, 2017 6:56 pm
Full Name: Aaron Barrett
Contact:

Re: Check days left in license for Veeam 10?

Post by abarrett »

Hey all,

I have the exact same issue.
A single Powershell session will keep the first results for Get-VBRInstalledLicense.

Process:

Code: Select all

Add-PSSnapin VeeamPSSnapin
Connect-VBRserver -Server VBR01 -User username -password password
$license1=Get-VBRInstalledLicense
$license1.InstanceLicenseSummary 
Disconnect-VBRserver
--
Connect-VBRserver -Server VBR02 -User username -password password
$license2=Get-VBRInstalledLicense
$license2.InstanceLicenseSummary 
$license1 and $license2 are these same. The workload VMs names are the same, and that's not possible.

Any update on this?

Thanks

Aaron

mwiles
Influencer
Posts: 17
Liked: 3 times
Joined: Jun 12, 2019 9:00 pm
Full Name: Michael Wiles
Contact:

Re: Check days left in license for Veeam 10?

Post by mwiles »

Had a working session with Veeam Support today and we recreated the issue together. Remove-Variable, Clear-Variable, nothing seemed to clear session information. The Engineer will work in his lab to recreate and see if he can find a resolution. I will update as I know more.

oleg.feoktistov
Veeam Software
Posts: 499
Liked: 167 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Check days left in license for Veeam 10?

Post by oleg.feoktistov » 1 person likes this post

Hi guys,

Tested your scripts in our labs for two VBRs v10 P2. Both return correct information and details for socket licensing, however for instance licensing it renders the same details for both servers. @mwiles, please let us know once support engineer investigated this. Meanwhile, I'll test it further and raise a question internally if needed.

Thanks,
Oleg

stressederic
Novice
Posts: 4
Liked: never
Joined: Jun 29, 2020 12:04 pm
Full Name: gareth roberts
Contact:

Re: Check days left in license for Veeam 10?

Post by stressederic »

I also have the same issue when obtaining InstanceLicenseSummary information.

The problem occurs even when I query 2 separate B&R servers in different scripts, as with abarrett if I call the scripts from the same powershell session the most values of the first script are returned for the second script.

Interestingly the value for LicensedInstancesNumber is correct but all other values return the results of the first B&R server queried

Code: Select all

PS > .\Veeam_License_Usage_REDACTED.ps1


LicensedInstancesNumber : 5385
UsedInstancesNumber     : 2640
NewInstancesNumber      : 88
RentalInstancesNumber   : 0


PS > .\Veeam_License_Usage_REDACTED.ps1



LicensedInstancesNumber : 6600
UsedInstancesNumber     : 2640
NewInstancesNumber      : 88
RentalInstancesNumber   : 0

mwiles
Influencer
Posts: 17
Liked: 3 times
Joined: Jun 12, 2019 9:00 pm
Full Name: Michael Wiles
Contact:

Re: Check days left in license for Veeam 10?

Post by mwiles »

I still am pending update from Engineering. So will post more as soon as I know.

abarrett
Novice
Posts: 3
Liked: never
Joined: Nov 20, 2017 6:56 pm
Full Name: Aaron Barrett
Contact:

Re: Check days left in license for Veeam 10?

Post by abarrett »

Obligatory Monthly bump. Any progress MWiles?

oleg.feoktistov
Veeam Software
Posts: 499
Liked: 167 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Check days left in license for Veeam 10?

Post by oleg.feoktistov »

Hi Aaron,

Confirmed as a bug. Scheduled to be fixed in v11.
Please, reach our support to check if a hotfix is available for that.
Michael's Case ID reference - 04213956.

Thanks,
Oleg

abarrett
Novice
Posts: 3
Liked: never
Joined: Nov 20, 2017 6:56 pm
Full Name: Aaron Barrett
Contact:

Re: Check days left in license for Veeam 10?

Post by abarrett »

Thanks Oleg!

mwiles
Influencer
Posts: 17
Liked: 3 times
Joined: Jun 12, 2019 9:00 pm
Full Name: Michael Wiles
Contact:

Re: Check days left in license for Veeam 10?

Post by mwiles »

sorry @abarrett, did not get notification of you asking. Thanks @oleg.feoktistov for replying.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests