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 (294k 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

After creating a user, I want to create a mailbox that is visible both on-premises and in Exchange Online (remote mailbox). The presence in on-premises Exchange is required ... migration is completed. The groups the user is being added to are license groups.

asked Oct 21 by Cas (200 points)
0 votes
1 answer

Pretty easy to replicate. On the Adaxes server, you can use Powershell to send to that SMTP server so we know it's not a firewall issue: $myCredential = Get- ... packet capture shows the Adaxes server doesn't issue either an EHLO or a STARTTLS command.

asked Jun 28 by ngb (290 points)
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 (50 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 (50 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)
3,589 questions
3,278 answers
8,303 comments
548,123 users