Script repository

Check if Adaxes license is close to violation

Updated on: Jan 18, 2026, Views: 5844

Miscellaneous

The script calculates the difference between the current number of enabled and not expired user accounts and that allowed by Adaxes license. If the difference is less than the specified threshold, the script returns $true. It should be executed in the If PowerShell script returns true condition in a business rule, custom command or scheduled task.

In the script, the $threshold variable specifies the threshold that should not be exceeded for the condition to be met.

$threshold = 100 # TODO: modify me

# Bind to the 'Service Settings' container.
$serviceSettingsContainerPath = $Context.GetWellKnownContainerPath("ServiceSettings")
$serviceSettingsContainer = $Context.BindToObject($serviceSettingsContainerPath)

# Get number of users allowed by license.
$productInfo = $serviceSettingsContainer.ProductInfo
$numberOfLicensedUsers = $productInfo.AllowedUserAccounts

if (($numberOfLicensedUsers -eq -2) -or ($numberOfLicensedUsers -eq -1))
{
    $Context.ConditionIsMet = $False
    return
}

# Get the number of enabled and not expired users
$numberOfEnabledAccounts = $productInfo.CalculateUserAccounts()

$Context.ConditionIsMet = ($numberOfLicensedUsers - $numberOfEnabledAccounts) -lt $threshold

Comments 3

You must be signed in to comment.

  • Wojciech Tauroginski

    Wojciech Tauroginski

    when i use it in scheduled task it sends me mulltiple emails but when i try to run it in powershell This script returns error:
    You cannot call a method on a null-valued expression.
    At line:3 char:1
    + $serviceSettingsContainerPath = $Context.GetWellKnownContainerPath("S ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At line:4 char:1
    + $serviceSettingsContainer = $Context.BindToObject($serviceSettingsCon ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At line:19 char:1
    + $numberOfEnabledAccounts = $productInfo.CalculateUserAccounts()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    The property 'ConditionIsMet' cannot be found on this object. Verify that the property exists and can be set.
    At line:21 char:1
    + $Context.ConditionIsMet = ($numberOfLicensedUsers - $numberOfEnabledA ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    • Support

      Support

      Hello Wojciech,

      >when i use it in scheduled task it sends me mulltiple emails

      It is expected in case you have multiple objects in the Activity Scope of the scheduled task. In this case, there must be only one object. For example, you can have a scheduled task configured for the Domain object type and add a single domain to the Activity Scope.

      >when i try to run it in powershell This script returns error

      The script only works in the If PowerShell script returns true condition in a business rule, custom command or scheduled task. If you attempt to execute the script in Windows PowerShell or in the Run a program or PowerShell script action, it is expected to fail.

      • Wojciech Tauroginski

        Wojciech Tauroginski

        Great i set it assigned over i service account user and not it works like a charm. Thank You

Got questions?

Support Questions & Answers

We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.