The script can be used in a business rule triggering Before modifying Microsoft 365 properties of a user to check whether a specific Microsoft 365 (Office 365) license is being assigned to a user. To execute the script, use the If PowerShell script returns true condition. It will return True if the license is being assigned.
Parameter:
- $licenseToCheck - Specifies the SKU Part Number of the Microsoft 365 (Office 365) license to check.
How to get the SKU Part Number of a license plan in Adaxes:
- In Adaxes Administration Console, expand the service node that represents your Adaxes service.
- Navigate to Configuration\Cloud Services and select Microsoft 365.
- Double-click the Microsoft 365 (Office 365) tenant to which the license belongs.
- Click the necessary license plan. The SKU Part Number is displayed below the Display Name field.
PowerShell
$licenseToCheck = "ENTERPRISEPACK" # TODO: modify me
# Get Microsoft 365 properties
$microsoft365Properties = New-Object Softerra.Adaxes.Adsi.CloudServices.AdmM365AccountProperties
$microsoft365Properties.LoadFromPropertyList($Context.Action.PropertyList)
# Check license
$Context.ConditionIsMet = $False
foreach ($license in $microsoft365Properties.Licenses)
{
if (($license.Assigned) -and ($license.Sku.SkuPartNumber -eq $licenseToCheck))
{
$Context.ConditionIsMet = $True
return
}
}
Hello,
What exactly is not working? Do you face any error messages? If so, please, provide us with screenshots. Also, please, provide us with the exact script you are using (with all your modifications) and a screenshot of the Business Rule executing the script.
I'm trying to use this but get 2 errors:
Exception calling "LoadFromPropertyList" with "1" argument(s): "Value cannot be null. Parameter name: propertyList" Stack trace: at <ScriptBlock>, <No file>: line 5
The property 'ConditionIsMet' cannot be found on this object. Verify that the property exists and can be set. Stack trace: at <ScriptBlock>, <No file>: line 8
According to the error message, you are using the script in Run a program or PowerShell script action, not in the If PowerShell script returns true condition. It will not work as the script is specifically dedicated for the condition only.
I want to check if an account has the necessary licenses (enterprisepack,enterprisepremum,exchangeenterprise) to it before doing a modification on it. So a powershell return true or false seems like a good option.
In the latest version of Adaxes, there is no need to use scripts to check Microsoft 365 licenses already assigned to a user. It can be done using the If is licensed for Microsoft 365 condition.
If you are using Adaxes 2020.1 or older, you can use the below script. For information on how to check the version of Adaxes you are currently using, have a look at the following help article: https://www.adaxes.com/help/CheckServiceVersion.
Great solution, keep up the good work!
Added a business rule "Before modifying Microsoft 365 properties of a user" and it runs the custom command when updating user M365 licenses.
I always get this log entry: "Check M365 License being assigned: No operations executed".
It doesn't matter if license is assigned or not. SKU is correct.
Sorry for the confusion, but we are not sure we understand your setup. Please, describe it in all the possible details with screenshots.
For your information, the script must be executed directly in a business rule triggering Before modifying Microsoft 365 properties of a user. It will never work in a custom command no matter where the command is executed.