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.

Script repository

Check if Adaxes license is close to violation

November 27, 2024 Views: 3219

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.

Edit Remove
PowerShell
$threshold = 100 # TODO: modify me

$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))
{
    # Adaxes service is still calculating the number of enabled and not expired
    # users or the license is unlimited
    $Context.ConditionIsMet = $False
    return
}

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

$Context.ConditionIsMet = ($numberOfLicensedUsers - $numberOfEnabledAccounts) -lt $threshold
Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers