0 votes

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

0 votes
by (272k points)

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

0 votes
1 answer

Hello, currently we have an Exchange 2019 Server in Hybrid configuration with Exchange Online. During our user onboarding a mailbox for the user is being created by a ... Remote-Mailboxes in this scenario for newly created AD-Users? Thanks and KR Christian

asked Apr 18 by User0815 (40 points)
0 votes
1 answer

Hello, we are in a migration phase from Exchange onPrem to Exchange Online. Since not all of our sites will be migrated at one time we are looking into a way to migrate ... an alerting / sending out a mail if the batch is not succesful? Thanks and KR Christian

asked Mar 21 by User0815 (40 points)
0 votes
1 answer

Howdy - Has anyone run into this message before? The changes never make their way through, I just have to manually do them. WIll I just need to create custom powershell scripts to achieve these items?

asked Feb 27 by ajblevins (20 points)
0 votes
1 answer

Hi, is it possible to export automatically the exchange online mailbox of a user to a .PST file on our archive server before the user is deleted? Kind regards, Fabian

asked Oct 26, 2023 by fabian.p (150 points)
0 votes
1 answer

Hi team, we see sometimes the following behavior: Changing a user mailbox to shared, is just moving on-prem mailbox of this user to shared. Online mailbox seems not to ... . What will happen with online mailbox? Will Adaxes generate a remote mailbox at all?

asked Oct 13, 2023 by wintec01 (1.1k points)
3,351 questions
3,052 answers
7,791 comments
545,079 users