You can only add up to 50 maximum number of email accounts, and if you wish to add more, you need to register your domain to Office 365 to have the desired members under your domain.
Error when adding many office users with powershell
marialozy
35
Reputation points
I'm trying to create a user (office365) using powershell a lot
Import-CSV –Path C:\PODCAST\file.csv |ForEach-Object { New-MsolUser -UserPrincipalName $_.username -DisplayName $_.displayname –Password $_.Password -UsageLocation $_.Location -LicenseAssignment $_. license -ForceChangePassword $false }
But after a while (only 100+ users too) an error will appear
New-MsolUser : You have exceeded the maximum number of allowable transactions. Please try again later.
At line:1 char:53
+ ... ch-Object { New-MsolUser -UserPrincipalName $_.username -DisplayName ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [New-MsolUser], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.ThrottlingException,Microsoft.Online.Administration.Automation.NewUser
Even though 2 days ago it still could.
5 answers
Sort by: Most helpful
-
-
marialozy 35 Reputation points
2023-03-31T08:50:48.6166667+00:00 New-MsolUser : You have exceeded the maximum number of allowable transactions.
Previously if too many powershell tabs (will error like that)
It's just one tab only error.
-
-
Stella Trice 0 Reputation points
2023-05-03T05:22:54.08+00:00 i have a same problem after microsft update
-
Rich Matheisen 47,596 Reputation points
2023-07-21T15:48:41.9+00:00 I haven't tested this, but it should handle the throttling problem. You can adjust the size of each batch and the pause between batches. I don't have access to M365 to come up with any good values for either of those.
$BatchSize = 100 $changes = 0 $DoIt = $true $pause = 5 Import-CSV -Path C:\PODCAST\4.csv | ForEach-Object { $props = @{ UserPrincipalName = $_.username DisplayName = $_.displayname Password = $_.Password UsageLocation = $_.Location LicenseAssignment = $_.license ForceChangePassword = $false ErrorAction = "STOP" } $changes++ if ($changes -ge $BatchSize){ Start-Sleep -Seconds $pause $changes = 0 } $DoIt = $true Do{ Try{ New-MsolUser @props $DoIt = $false # no error, so don't retry } Catch{ If ($_.FullyQualifiedErrorId -like "*Microsoft.Online.Administration.Automation.ThrottlingException*"){ Start-Sleep -Seconds $pause } else{ # handle error here, or just report it and skip current user $DoIt = $false # stop any retries } } } While ($Doit) }