IAdmM365LicenseCondition
The IAdmM365LicenseCondition interface represents the If is licensed for Microsoft 365 condition.
Inheritance: IAdmCondition
Properties
-
Property
-
Description
-
ConditionType
-
Gets or sets a value indicating what is checked by the condition.
-
LogicalOperator
-
Gets or sets the logical operator that determines how to check Microsoft 365 services or licenses assigned to a user.
-
LicenseRequirements
-
Gets or sets a list of Microsoft 365 licenses that should be enabled or disabled to meet the condition.
-
ServiceRequirements
-
Gets or sets a list of Microsoft 365 services that should be enabled or disabled to meet the condition.
Details
ConditionType
Gets or sets a value indicating what is checked by the condition. The condition can check whether at least one Microsoft 365 license is assigned to a user or whether this user has specific licenses.
- Type:
- ADM_M365ACCOUNT_CONDITION_TYPE_ENUM
- Access:
- Read/Write
LogicalOperator
Gets or sets the logical operator that determines how to check Microsoft 365 licenses or services assigned to a user.
- Type:
- ADM_LOGICALOPERATION_ENUM
- Access:
- Read/Write
Remarks
The property is taken into account only if the ConditionType property is set to ADM_M365ACCOUNT_CONDITION_TYPE_SERVICESPECIFIC or ADM_M365ACCOUNT_CONDITION_TYPE_LICENSESPECIFIC.
-
Value
-
Condition is met
-
ADM_LOGICALOPERATION_AND
-
All of the user's Microsoft 365 licenses or services must match the licenses or services specified in the
LicenseRequirementsor theServiceRequirementsproperty, depending on the value ofConditionType. -
ADM_LOGICALOPERATION_OR
-
At least one of the user's Microsoft 365 licenses or services must match the licenses or services specified in the
LicenseRequirementsor theServiceRequirementsproperty, depending on the value ofConditionType.
LicenseRequirements
Gets or sets the requirements to the state of the Microsoft 365 licenses.
- Type:
- IAdmM365LicenseStateRequirement[]
- Access:
- Read/Write
Remarks
The property is taken into account only if the IAdmM365LicenseCondition::ConditionType property is set to ADM_M365ACCOUNT_CONDITION_TYPE_LICENSESPECIFIC.
Examples
The following code sample creates a condition that returns true if the target object has the Microsoft 365 license ENTERPRISEPACK.
- Powershell
-
# The $actionSet variable refers to an action set in a # business rule, custom command, or scheduled task. # Create condition. $condition = $actionSet.Conditions.CreateEx("adm-O365LicenseCondition") $licenseCondition = $condition.GetCondition() $licenseCondition.ConditionType = "ADM_M365ACCOUNT_CONDITION_TYPE_LICENSESPECIFIC" $licenseRequirements = $licenseCondition.LicenseRequirements foreach ($requirement in $licenseRequirements) { $license = $requirement.License if ($license.Sku.SkuPartNumber -eq "ENTERPRISEPACK") { $requirement.Enabled = $true $requirement.LicenseState = $true break } } $licenseCondition.LicenseRequirements = $licenseRequirements # Save changes. $condition.SetCondition($licenseCondition) $condition.SetInfo() $actionSet.Conditions.Add($condition) - C#
-
// The actionSet variable refers to an action set in a // business rule, custom command, or scheduled task. // Create condition. IAdmBusinessRuleCondition condition = (IAdmBusinessRuleCondition)actionSet.Conditions.CreateEx( "adm-O365LicenseCondition"); IAdmM365LicenseCondition licenseCondition = (IAdmM365LicenseCondition)condition.GetCondition(); licenseCondition.ConditionType = ADM_M365ACCOUNT_CONDITION_TYPE_ENUM.ADM_M365ACCOUNT_CONDITION_TYPE_LICENSESPECIFIC; IAdmM365LicenseStateRequirement[] licenseRequirements = licenseCondition.LicenseRequirements; foreach (IAdmM365LicenseStateRequirement requirement in licenseRequirements) { IAdmM365License license = (IAdmM365License)requirement.License; if (license.Sku.SkuPartNumbe == "ENTERPRISEPACK") { requirement.Enabled = true; requirement.LicenseState = true; } } licenseCondition.LicenseRequirements = licenseRequirements; // Save changes. condition.SetCondition(licenseCondition); condition.SetInfo(); actionSet.Conditions.Add(condition);
ServiceRequirements
Gets or sets a list of Microsoft 365 services that must be enabled or disabled to meet the condition.
- Type:
- IAdmM365ServiceStateRequirement[]
- Access:
- Read/Write
Remarks
The property is taken into account only if the ConditionType property is set to ADM_M365ACCOUNT_CONDITION_TYPE_SERVICESPECIFIC.
Examples
The following code sample creates a condition that returns true if:
- The Office Professional Plus service is enabled.
- The SharePoint Online (Plan 2) service is disabled.
- PowerShell
-
# The $actionSet variable refers to an action set in a # business rule, custom command, or scheduled task. # Create condition. $condition = $actionSet.Conditions.CreateEx("adm-O365LicenseCondition") $microsoft365LicenseCondition = $condition.GetCondition() $microsoft365LicenseCondition.ConditionType = "ADM_M365ACCOUNT_CONDITION_TYPE_SERVICESPECIFIC" $serviceRequirements = $microsoft365LicenseCondition.ServiceRequirements foreach ($requirement in $serviceRequirements) { if ($requirement.Service.ServiceName -eq "OFFICESUBSCRIPTION") { $requirement.Enabled = $true $requirement.ServiceState = $true } elseif ($requirement.Service.ServiceName -eq "SHAREPOINTENTERPRISE") { $requirement.Enabled = $true $requirement.ServiceState = $false } } $microsoft365LicenseCondition.ServiceRequirements = $serviceRequirements # Save changes. $condition.SetCondition($microsoft365LicenseCondition) $condition.SetInfo() $actionSet.Conditions.Add($condition) - C#
-
// The actionSet variable refers to an action set in a // business rule, custom command, or scheduled task. // Create condition. IAdmBusinessRuleCondition condition = (IAdmBusinessRuleCondition)actionSet.Conditions.CreateEx( "adm-O365LicenseCondition"); IAdmM365LicenseCondition microsoft365LicenseCondition = (IAdmM365LicenseCondition)condition.GetCondition(); microsoft365LicenseCondition.ConditionType = ADM_M365ACCOUNT_CONDITION_TYPE_ENUM.ADM_M365ACCOUNT_CONDITION_TYPE_SERVICESPECIFIC; IAdmM365ServiceStateRequirement[] serviceRequirements = microsoft365LicenseCondition.ServiceRequirements; foreach (IAdmM365ServiceStateRequirement requirement in serviceRequirements) { if (requirement.Service.ServiceName == "OFFICESUBSCRIPTION") { requirement.Enabled = true; requirement.ServiceState = true; } else if (requirement.Service.ServiceName == "SHAREPOINTENTERPRISE") { requirement.Enabled = true; requirement.ServiceState = false; } } microsoft365LicenseCondition.ServiceRequirements = serviceRequirements; // Save changes. condition.SetCondition(microsoft365LicenseCondition); condition.SetInfo(); actionSet.Conditions.Add(condition);
Requirements
Minimum required version: 2023