I have a script that adds a mailbox permission to all users, but it is getting throttled after switching to the new app registration authentication. Is there any way to prevent this?

Fail to create runspace because you have exceeded your budget to create runspace. Please wait for 26 seconds.

try
{
    # Get the object ID in Office 365
    $objectId = [Guid]$Context.TargetObject.Get("adm-O365ObjectId")
}
catch
{
    return # The user doesn't have an Office 365 account
}

try
{
$session = $Context.CloudServices.CreateExchangeOnlinePSSession()
Import-PSSession $session -AllowClobber -DisableNameChecking -CommandName "Add-MailboxPermission"

 # Change mailbox type
    Add-MailboxPermission $objectId.ToString() -User "company administrator" -AccessRights 'FullAccess'
}
finally
{
    # Close the remote session and release resources
    if ($session) { Remove-PSSession $session }
}
by (540 points)

1 Answer

by (309k points)
0 votes

Hello,

This behaviour is expected as the script establishes a new connection for each user. The issue is not related to Adaxes and is devoted to the limits of Exchange Online. To achieve the desired, you need to use a single connection to delegate all the permissions.

Unfortunately, we are currently very limited in resources and have no possibility to write and test the updated script for you. Should you, have issues doing it yourself, we encourage you to address the request to our consulting partners that provide professional services: https://www.adaxes.com/purchase_consultants.htm. Sorry for the inconvenience and thank you for your understanding.

Related questions

No edit button is available within Adaxes for these accounts. The service account has 'Mail Recipients' and 'MailRecipientCreation' permissions assigned. What additional configuration or permissions might be needed?

asked May 29 by HappyOtter6153 (20 points)
0 votes
1 answer

We are using Adaxes Directory Object Picker for selecting Distribution Group members. We create external recipients as Exchange Online MailContacts (via New-MailContact). These contacts: are ... Context: We are using cloud-only contacts (no on-prem AD sync).

asked May 27 by IwistIT (140 points)
0 votes
1 answer

I need to connect to Exchange Online using specific service principal, but I am getting error I am trying to authenticate via Connect-ExchangeOnline -AccessToken $token - ... btw aka 3.8.0 version of the ExchangeOnlineManagement module is used automatically.

asked Nov 18, 2025 by KIT (1.1k points)
0 votes
1 answer

Hi, when I enable a license for Exchange Online for a user I get the following warning: Here are the current settings for creating a remote ... : InvalidOperation: (:) [], RuntimeException     + FullyQualifiedErrorId : PropertyAssignmentException

asked Nov 18, 2025 by Allister (90 points)
0 votes
1 answer

Hello, We've previously had assistance in implementing a method to transfer email addresses to a specified user via a powershell script for our on-prem Exchange. This has ... $user.SetInfo() Please let me know if you require more clarification. Regards, Josh

asked Aug 25, 2025 by jtop (720 points)
0 votes
1 answer