Microsoft on-premises server product that runs Office Online.
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)
}