How to calculate Censornet FMA Licenses remaining

This is write-up on how to calculate the remaining user licenses in a Censornet FMA , SMS passcode, deployment. Since the version 9 release, Censornet FMA supports Powershell and I wanted to know if it was possible to create a script that could calculate the number of available licenses.

First try

For me personally, Powershell is an area that is not my primary expertise. So I spend some time reading about the available Powershell commands for the SMS passcode 9 product. I could not find what I needed so I contacted Censornet support if they could help me in finding a solution.They came back with the following code that will show you the number of available licenses. Please note that the following script is for Powershell 3.0 and up (if you want the script for 2.0, Censornet has a 2.0 version available).

$LicensesInUse = Get-SmsPcLicense | Select-Object -ExpandProperty LicenseStatisticsInUseCount
$LicensesAvailable = Get-SmsPcLicense | Select-Object -ExpandProperty LicenseStatisticsAvailableCount

$Result = [Ordered]@{}
$LicensesAvailable.GetEnumerator() | ForEach-Object {
    $Result.($_.Key) = $_.Value - $LicensesInUse.($_.Key)
}
$Result

The output of the script is in the image below and as you can see I have 3 types of licenses in my environment.

Censornet FMA licenses available output

 

 

 

Final result

For my reporting I only wanted the ‘FMA Standard’ available licenses and, with some great support from Gunnar Hermansen, the result is in the following script:

$mailFrom = "censornetFMA @martijnhs.com" 
$mailSubject = "Censornet FMA Licenses left" 
$mailTo = "somebody @martijnhs.com" 
$mailServer = "MailServer" 
$LicType = "MFA Standard" 
 
 
$LicensesInUse = Get-SmsPcLicense | Select-Object -ExpandProperty LicenseStatisticsInUseCount 
$LicensesAvailable = Get-SmsPcLicense | Select-Object -ExpandProperty LicenseStatisticsAvailableCount 
 
$Result = [Ordered]@{} 
$LicensesAvailable.GetEnumerator() | ForEach-Object { 
    $Result.($_.Key) = $_.Value - $LicensesInUse.($_.Key) 
} 
$Result2 = "The number of available FMA licenses is " + $result.$LicType 
 
$result2 
 
Send-MailMessage -From $mailFrom -Subject $mailSubject -To $mailTo -Body $result2 -Port 25-SmtpServer $mailServer

Please test this in your own lab environment before using it in production. Have fun and relax when monitoring Censornet FMA licenses.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.