Script Repository


Check number of unused user accounts allowed by Adaxes license

May 27, 2019
1431

The script can be used to check the number of enabled user accounts that you can create in your Active Directory 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.AllowedEnabledUserAccounts

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.CalculateTotalNumberOfEnabledAccounts()

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

Comments ( 0 )
No results found.
Leave a comment