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 number of unused user accounts allowed by Adaxes license

February 28, 2023 Views: 3159

The script can be used to check the number of enabled user accounts that you can create in your managed domains without exceeding the number of users allowed by Adaxes license. You can run the script as a part of a business rule, custom command or scheduled task. To add it to your rule, command or task, use the If PowerShell script returns true condition. The condition returns true when the number of remaining accounts is below the limit specified in the script.

For example, you can use such a condition to receive email notifications when the number of remaining accounts allowed by your license is too low. Task sample:

Parameter:

  • $limit - Specifies the minimum number of remaining accounts. The script will return true if the actual number of remaining account is below this limit.
Edit Remove
PowerShell
$limit = 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 $limit
Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers