The script generates a report containing users assigned the specified Microsoft 365 licenses. To execute the script, create a report with the corresponding custom column. The report should have a scope configured. In the report, Microsoft 365 licenses will be identified using their display names specified in the Microsoft 365 tenant settings.
Parameters:
- $licensesColumnID - Specifies the identifier of the custom column that will store the assigned licenses. The column should be of the Text type. To get the identifier of a custom column:
- In the Report-specific columns section, on the Columns tab, right-click the custom column.
- In the context menu, navigate to Copy and click Column ID.
- The column identifier will be copied to clipboard.
- $licensesParameterName - Specifies the name of the Checkbox list parameter used to select the licenses for report generation with the param- prefix. The values for selected items must be set to the SKU part numbers of the licenses.
- $separator - Specifies the separator entered in the settings of the Checkbox list parameter for selecting licenses.
PowerShell
$licensesColumnID = "{6e2ae115-7c27-4b52-a2d4-5e9d943edc92}" # TODO: modify me
$licensesParameterName = "param-Licenses" # TODO: modify me
$separator = ";" # TODO: modify me
# Get licenses to check
$licensesToCheck = $Context.GetParameterValue($licensesParameterName).Split($separator)
$criteria = New-AdmCriteria "user"
$Context.DirectorySearcher.AddCriteria($criteria)
try
{
$searchIterator = $Context.DirectorySearcher.ExecuteSearch()
while ($Context.MoveNext($searchIterator))
{
$searchResult = $searchIterator.Current
$user = $Context.BindToObjectBySearchResult($searchResult)
try
{
$office365Properties = $user.GetMicrosoft365Properties()
}
catch
{
continue
}
# Get Microsoft 365 licenses available for the user
$licenses = $office365Properties.Licenses
$licenseNames = New-Object System.Collections.ArrayList
foreach ($license in $licenses)
{
if (!($license.Assigned))
{
continue
}
if ($licensesToCheck -notcontains $license.Sku.SkuPartNumber)
{
continue
}
$licenseNames.Add($license.Sku.DisplayName)
}
if ($licenseNames.Count -eq 0)
{
continue
}
# Add user to the report
$Context.Items.Add($searchResult, @{ $licensesColumnID = ($licenseNames -join ";") }, $NULL)
}
}
finally
{
# Release resources
if ($searchIterator) { $searchIterator.Dispose() }
}
The pipeline has been stopped.
Is there a limitation that can be adjusted to allow a larger scope?
The behavior is not related to Azure AD itself. The error is displayed because the time for the script execution exceeds the timeout set in Adaxes. By default, it is 10 minutes. It is recommended to just use scopes that allow the script to complete within the timeout. But if you want to increase it, please, specify the version of Adaxes you are currently using and we will get back to you with detailed instructions. For information on how to check your Adaxe version, see https://www.adaxes.com/help/CheckServiceVersion.
Thank you for the response and assistance. We are using version 3.15.20916.0.
Thank you for specifying. For details on how to manage configuration parameters, have a look at the following help article: https://www.adaxes.com/help/ChangeConfigurationParameters. You need to change the value of the Adsi.ScriptExecutionTimeout parameter.