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 (530 points)

1 Answer

0 votes
by (226k 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
0 answers

Is there a way to run this report against Exchange Online instead of a local Exchange server?

asked Jul 13 by RayBilyk (220 points)
0 votes
1 answer

When creating a hybrid user mailbox with a Business Rule, after user creation, the remote routing address of the mailbox is set to the users email alias. How do I set it to the 365 address username@ourdomain.mail.onmicrosoft.com

asked Apr 13 by john.harding (70 points)
0 votes
1 answer

Hi Team! I'm currently looking for a solution to create an exchange mailbox on-premise, sync it to Office 365 and assign the license in one business rule. I didn't ... solution from our side? Please let me know how to configure this. Best Regards Marco Jandl

asked Apr 6 by marco_jandl (60 points)
0 votes
1 answer

Hi Team I need some assitance with creating a report to pull from exchange online all user mailboxes that have automatic replies enabled. I have been attempting to use ... Where-Object { $_.AutoReplyState -ne "Disabled" } | Select Identity, StartTime, EndTime

asked Aug 25, 2021 by Richard_NRL (90 points)
0 votes
1 answer

I'm testing making changes to a mailbox that is synced between AD and Office365. During changes updates are not reflected back. I'm prompted that the replication with AD Connect has ... in the web interface. If I go to the console I can see the change.

asked Aug 6, 2020 by ComputerHabit (790 points)
2,779 questions
2,512 answers
6,574 comments
26,276 users