0 votes

I used this script from the repository https://www.adaxes.com/script-repository/check-if-number-of-unused-microsoft-365-licenses-is-below-limit-s594.htm

I have amended to include the skus I am concerned about so it now shows this:

$limit = 2 # TODO: modify me
$skus = @("ENTERPRISEPACK","EMS") # TODO: modify me

$Context.ConditionIsMet = $False
$tenantDN = "%adm-AssociatedO365Tenant%"
if ([System.String]::IsNullOrEmpty($tenantDN))
{
    $Context.LogMessage("No Microsoft 365 tenant is associated with the user", "Error")
    return
}

# Bind to Microsoft 365 tenant
$tenant = $Context.BindToObjectByDN($tenantDN)

# Check licenses
foreach ($sku in $tenant.Skus)
{
    if (($skus -ne $NULL) -and ($skus -notcontains $sku.SkuPartNumber))
    {
        continue
    }

    $difference = $sku.TotalUnits - $sku.ConsumedUnits
    if ($difference -gt $limit)
    {
        continue
    }

    $Context.ConditionIsMet = $True
}

I am using this in the 'Before user creation' area: image.png

I just want to receive an email when the license count is below what I specify.

Please can you advise what I am doing wrong.

by (110 points)
0

Hello,

The script and the configuration look correct. Please, clarify what makes you think that something is wrong. Did you try creating a user when the number of the Microsoft 365 licenses in question is below the specified number?

0

Hi,

Yes exactly that, I tried creating the user when we had 0 licenses and the email did not send.

0

Hello,

Thank you for specifying. For further troubleshooting, please, post here or send us at support@adaxes.com the following:

  • A screenshot of the Send email notification action configuration. We need something like this: image.png

  • A screenshot of the Create user operation Execution log. To take the screenshot:

    1. Launch the Adaxes Administration console.
    2. In the Console Tree, expand your service node.
    3. Select Logging.
    4. In the Result Pane on the right, select the required Time period (e.g. Today if the user was created today).
    5. Click the down arrow embedded into the Filter Operation field.
    6. In the drop-down list, select Create. image.png
    7. In the Filter Operation field, type the name of the user you created.
    8. Right-click the log record for the Create user operation and then click Properties. image.png
    9. Resize the Log Record Properties window to fit all Execution log records.
    10. If the execution log is too big to fit a screenshot, select all records using Ctrl+A, copy them and send to us in TXT format.
0

Hi,

Here are the screenshots as requested.

image.png

image.png

+1

Hello,

Thank you for the provided screenshots. According to the very first error in the Execution log, the account is created in the container that is not included into the Associated Directory Scope of the Microsoft 365 tenant registered in Adaxes.

0

thank you

1 Answer

0 votes
by (550 points)

I also use the above script and it usually works very well, only when I have freshly cleaned up the license pool it takes about 2h until the check is up to date again. Can I also achieve a faster update in Adaxes?

0

Hello Boris,

The easiest way is to just update Microsoft 365 tenant data manually after the changes to licenses/services are made: image.png As another option, you can update parameter O365.UpdateTenantDataPeriod as described in the following article: https://www.adaxes.com/help/ChangeConfigurationParameters.

0

Thanks for the link, exactly what I needed. Perfect.

0

Is it possible to adapt the script so that it can be used in a report and the availability can be displayed directly on the homepage:

image.png

I have tried this, but unfortunately without success.

0

Hello Boris,

You can try using the following script fromk our repository: https://www.adaxes.com/script-repository/microsoft-365-licenses-information-s630.htm. If that is not what you need, please, describe the exact desired behavior in all the possible details with live exampels and possibly screenshots.

Related questions

0 votes
1 answer

Hi, I used this script from the repository https://www.adaxes.com/script-repository/check-if-number-of-unused-microsoft-365-licenses-is-below-limit-s594.htm which works fine, but ... creation form, so I can see if whether it makes sense to fill out the form

asked Apr 3 by boris (550 points)
0 votes
1 answer

Hi Team, We are using a set of form/business rules/custom commands for user creation that move user account to the right OU given the Office attribute value. I would ... , but can't find valuable information on the web site. Thanks in advance Regards Stephen

asked Dec 12, 2012 by sroux (800 points)
0 votes
1 answer

Hi, I need a bit of scripting help within Adaxes. We have a number of o365 licence checks that occur, some on a schedule, some before creating a ... $to -from $from -SmtpServer $smtpServer -Subject $messageSubject -Body $messageBody Remove-PSSession $session

asked Dec 13, 2022 by gazoco (490 points)
0 votes
1 answer

Hi there we use personal identity number in one of our customattribute. How would you script this so it checks that the number that we specify when filling out the form ... process should be interupted and we then know that that user already has an account.

asked Jun 19, 2019 by ahok (50 points)
0 votes
0 answers

When attempting to assign licenses during the "after creating a user" rule we're reciving the following error. Failed to create a remote mailbox for the user. The address ' ... mail attribute to the proper format that isn't the onmicrosoft.com domain as well.

asked Sep 2, 2021 by zorps (20 points)
3,588 questions
3,277 answers
8,303 comments
548,086 users