New-MsolUser : You have exceeded the maximum number of allowable transactions. Please try again later.

marialozy 35 Reputation points
2023-03-31T14:44:05.8433333+00:00

I've been using this code for more than 2 months.

And just got error 2 today ago.

So I use this code :

Import-CSV –Path C:\Office\4.csv |ForEach-Object { New-MsolUser -UserPrincipalName $_.username -DisplayName $_.displayname –Password $_.Password -UsageLocation $_.Location -LicenseAssignment $_. license -ForceChangePassword $false }

At first you can but over time it will fail, the message appears:

New-MsolUser : You have exceeded the maximum number of allowable transactions. Please try again later.
At line:1 char:52
+ ... ch-Object { New-MsolUser -UserPrincipalName $_.username -DisplayName ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
     + CategoryInfo : OperationStopped: (:) [New-MsolUser], MicrosoftOnlineException
     + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.ThrottlingException,Microsoft.Online.Administration.Automation.NewUser

After he made an error, he can do it again later.

The problem is why You have exceeded the maximum number of allowable transactions. ??

What went wrong so : New-MsolUser : You have exceeded the maximum number of allowable transactions. Please try again later.

I'm very sure this is the office, because I use 2 different admins there are still errors.

As I have attached, for example when I created 12k users, only 10k succeeded, 2k failed.

Please help me

contoh-1

contoh 2

Screenshot_2

I'm pretty sure the problem is not with the code, but with Microsoft.

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,578 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,553 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,596 questions
{count} vote

Accepted answer
  1. Rich Matheisen 46,811 Reputation points
    2023-03-31T15:52:55.2033333+00:00

    I don't know what the throttling limits are for you, but start with something like this and adjust the $batchSize and/or $pause values as necessary:

    $batchSize = 10
    $batchCount = 0
    $pause = 5
    Import-Csv –Path C:\Office\4.csv | 
        ForEach-Object { 
            if ($batchCount -eq $batchSize){
                Start-Sleep -Seconds $pause
                $batchCount = 0
            }
            New-MsolUser -UserPrincipalName $_.username -DisplayName $_.displayname –Password $_.Password -UsageLocation $_.Location -LicenseAssignment $_. license -ForceChangePassword $false 
            $batchCount++
        }
    

4 additional answers

Sort by: Most helpful
  1. Vasil Michev 108.1K Reputation points MVP
    2023-03-31T15:13:01.1333333+00:00

    You are hitting the throttling limits. Add a small delay between cmdlet executions or do them in smaller batches, and you should be fine.

    1 person found this answer helpful.

  2. JLA 5 Reputation points
    2023-04-01T13:46:37.89+00:00

    Sorry to be the bearer of bad news, but you are aware about the retirement of the MSonline license assignment scripts?
    https://techcommunity.microsoft.com/t5/microsoft-entra-azure-ad-blog/migrate-your-apps-to-access-the-license-managements-apis-from/ba-p/2464366

    Since your issue started 31st of march, which is exactly the announced retirement date for the commands you're using, you might want to consider porting this script to MS Graph...

    1 person found this answer helpful.

  3. Chris King 0 Reputation points
    2023-05-09T17:46:23.8466667+00:00

    I am not sure where you're seeing the march 31st date and I cannot be sure when my daily licensing script started hitting the throttling limits. By adding a 5 second delay I was able to get batches of 30 or so working and got caught up.

    But like many of these retirement announcements you can never easily get an exact date nor any details on things like this throttling be done. Also, MS constantly pushes dates out.

    But yeah, working on updating my scripts.

    0 comments No comments

  4. AB123 351 Reputation points
    2023-09-08T12:38:07.9433333+00:00

    I have using: ## Bulk Remove licenses ## ## Select Csv file $csv = Get-ChildItem -Path C:\temp\Office365Licence\Remove\ -File | Out-GridView -PassThru ## Import Csv $users = Import-Csv $csv.FullName ## Select Account SKU to be removed $accountSKU  = Get-MsolAccountSku | Select-Object AccountSkuId | Out-GridView -PassThru ## Loop through each user in the Csv foreach($user in $users){ Write-Host "Removing $($accountSKU.AccountSkuId) licence from $($user.UserPrincipalName)" -ForegroundColor Yellow ## Remove licence Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -RemoveLicenses $accountSKU.AccountSkuId }

    Which removes license off bulk users however only does like 5 before it exceeds limit, what would the script be via ms graph?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.