You have Exceeded the Maximum Number of Allowable Transactions Microsoft 365

Table of Contents

Exceeded the maximum number of allowable transactions

I’ve been using the following script, to bulk assign licenses to multiple users at once for years.

Get-MsolUser -All -UnlicensedUsersOnly | ForEach-Object {
  Set-MsolUserLicense `
  -UserPrincipalName $_.UserPrincipalName `
  -AddLicenses 'M365t66166641:POWER_BI_STANDARD'
}

However, recently I am getting the following error, I’m not sure what is causing it and I have tried over a couple of hours, but the same issue occurs. The licenses do not assign to all users, and I have a couple hundred users without a license.

Set-MsolUserLicense : You have exceeded the maximum number of allowable transactions. Please try again later.
At line:10 char:1
+ Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses $SKU

Entra ID PowerShell Deprecation

Microsoft’s original announcement about the deprecation of the Entra ID and Microsoft Online Services (MSOL) PowerShell modules.

You have Exceeded the Maximum Number of Allowable Transactions Microsoft 365

Assign License to Users using Microsoft Graph

1️⃣ Open Windows PowerShell as administrator then run the following commands to install Microsoft Graph Api PowerShell modules.

##Add Repopsitory
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force
Install-PackageProvider -Name NuGet -Force
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted

##Install modules
Install-Module Microsoft.Graph -Scope CurrentUser -Force
Install-Module MSAL.PS -Scope AllUsers -Force

2️⃣ Use the Connect-MgGraph command to sign in with the required scopes. You’ll need to sign in with an admin account to consent to the required scopes.

Connect-MgGraph -Scopes User.ReadWrite.All, Organization.Read.All
You have Exceeded the Maximum Number of Allowable Transactions Microsoft 365

Note: Finding the right scope can be a bit challenging at the beginning. You can visit this link to get more information about scopes.

3️⃣ Get the list of licenses in your tenant:

PS C:\> Get-MgSubscribedSku | select SkuPartNumber, SkuId, ConsumedUnits

SkuPartNumber       SkuId                                ConsumedUnits
-------------       -----                                -------------
CPC_E_2C_8GB_256GB​ 1c79494f-e170-431f-a409-428f6053fa35             0
CPC_E_2C_4GB_128GB​ 226ca751-f0a4-4232-9be5-73c02a92555e             0
POWER_BI_STANDARD   a403ebcc-fae0-4ca2-8c8c-7a907fd6c235           159
SPE_E5              06ebc4ee-1bb5-47dd-8120-11324bc54e06            22

4️⃣ Finally, bulk assign license for all users using Graph PowerShell instead of MSOL PowerShell.

$Sku = Get-MgSubscribedSku -All | Where SkuPartNumber -eq 'POWER_BI_STANDARD'
$users = Get-MgUser -Filter "assignedLicenses/`$count eq 0 and userType eq 'Member'" `
        -ConsistencyLevel eventual -CountVariable unlicensedUserCount -All

foreach ($user in $users) {
    Set-MgUserLicense -UserId $user.Id `
    -Addlicenses @{SkuId = $Sku.SkuId} `
    -RemoveLicenses @()
}

More Microsoft Graph PowerShell articles

Leave a Comment

Required fields are marked *