Powershell: Veeam B&R – Get total days before the license expires

So it’s time for a new post with some “traditional” Powershell so no snappins from VMware or Veeam. But first some background info. I am working for a Veeam ProPartner  with a Service Provider partner program. in this program Veeam only supplies “temporary licenses” so you have to deal with an expiration date of the license. This also applies to the Veeam NFR licenses for vExperts, VCP, MVP, etc. But how do you get notified when the license is about to expire? Well I don’t know if there is an option for that, maybe in the Enterprise Portal but as far as I know will it only display an error when the license key is expired.

I decided to dive under the hood and tried to find the places where Veeam B&R holds the license information. I couldn’t find the license info with the Veeam Powershell Toolkit. So the next step was to find the info inside the Veeam Backup Database but I couldn’t find it either inside the database. The last step was the right one. The license information is kept inside the Windows registry in the following key:

HKLM\SOFTWARE\VeeaM\Veeam Backup and Replication\license

But the info is saved in a REG_BINARY so it’s harder to extract. But lucky me Tim Dunn wrote a simple one-liner to extract this data. So I added this to my script:

$regBinary = (Get-Item 'HKLM:\SOFTWARE\VeeaM\Veeam Backup and Replication\license').GetValue('Lic1')
$veeamLicInfo = [string]::Join($null, ($regBinary | % { [char][int]$_; }))

The $regBinary variable gets the data from the registry key. The $veeamLicInfo variable converts the $regBinary into human readable lines of text. So now we extracted the license info, we only need write a RegEx to extract the info we need to create a notification e-mail. So take a look at the $pattern variable which will search for:
“EXPIRATION DATE=MM/DD/YYYY”

The $expirationDate variable will execute the RegEx and it saves the first match via [0]. After that the match will be splitted and the the value after the “=” character will be used as the expiration date.

So now we have the expiration date but how do we calculate the remaining days. Well that’s exactly what the code, that fills the $totalDaysLeft variable does.

So here you will find the complete script:

Warning: this script is only tested on Veeam Backup & Replication version 5. So I don’t know if the script will work on version 6 too.

Update: If you want to use the following script with Veeam Backup & Replication v6. You only have to change the $pattern variable to: $pattern = expiration date\=\d{1,2}\/\d{1,2}\/\d{1,4}

#http://blogs.msdn.com/b/timid/archive/2011/06/17/stupid-tricks-with-reg-binary-registry-data.aspx <- $regBinary trick
#http://stackoverflow.com/questions/622902/powershell-tips-tricks-for-developers <- regex tips

$regBinary = (Get-Item 'HKLM:\SOFTWARE\VeeaM\Veeam Backup and Replication\license').GetValue('Lic1')
$veeamLicInfo = [string]::Join($null, ($regBinary | % { [char][int]$_; }))
$pattern = "EXPIRATION DATE\=\d{1,2}\/\d{1,2}\/\d{1,4}"
$expirationDate = [regex]::matches($VeeamLicInfo, $pattern)[0].Value.Split("=")[1]
$totalDaysLeft = [System.Math]::Round(((Get-Date $expirationDate) - (get-date)).Totaldays, 0)
write-Host "The Veeam License will expire in $($totalDaysLeft) days." -foregroundcolor Yellow

Send-MailMessage -to "Arne Fokkema <a.fokkema@ict-freak.local>" -cc "Alerts <alerts@ict-freak.local>" `
-from "Veeam Server <veeam@ict-freak.local>" -subject "Veeam License Check" -BodyAsHtml `
-body "The Veeam License will expire in $($totalDaysLeft) days." -smtpServer smtp.ict-freak.local

You can change the parameters of the Send-MailMessage and schedule a task op your Veeam server to report the total times left before the license will expire.

Add an ESX 3.x host to your vSphere Cluster

image

If you add an ESX 3.5 host to your vSphere Cluster,there is a change you’ll get this warning:

image

The solution is simple, you need the “old” license server running in your network. So download the “old” license server from http://vmware.com/download/vi/drivers_tools.html

image

Install the License Server for ESX 3.5 on different server than your vCenter box. I tried installing it on the same box, but it ended with a failed startup of the License server services. The installation is straight forward (read next, next, add license file, next and finish).

After the installation open the vCenter Service Settings option.

 image

And enter the address of your license server and press ok.

image 

Now it’s possible to add the ESX 3.5 host to your cluster.

Citrix: EventID 3 and EventID 7023 (Citrix WMI)

Nadat ik op een Citrix Server, met een Advanced licentie de Citrix WMI providers had geïnstalleerd, liep de evenlog’s vol met EventID 3

EventID3

en EventID 7023.

EventID7023

Je kunt alleen gebruik maken van de Citrix WMI providers als je een Enterprise of Premium licentie hebt.

Microsoft: Terminal Server Client Calls Activation

 tslogo

Vandaag ging ik mijn 20 nieuwe client calls invoeren in mijn Windows Server 2003 Terminal servicese license server. Ik opende de Terminal Server Licensing mmc .

Vervolgens klik je met rechts op de licenserver gevolgd door Install Licenses.

TSActivation_1

Het welcome scherm verschijnt.

TSActivation_2

Nadat je op next geklikt hebt, krijg je het onderstaande scherm. Onthoud het License server ID. Deze heb je nodig in het verdere process.

TSActivation_3

Nu kun je uit twee opties kiezen;

  1. Activeren via https://activate.microsoft.com
  2. Bellen met het nummer 020-3469363

Ik koos eerst voor optie 1. Na dit een keer of vier geprobeerd te hebben, lukte het niet. Toen heb ik het maar via de telefoon gedaan via het telefoonnummer vermeld bij optie 2. Dit is alleen zo’n vervelend iets omdat je zoveel nummers moet opnoemen. Maargoed het is gelukt!

Follow

Get every new post delivered to your Inbox.

Join 975 other followers