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

Hi All, I'm trying to use the powershell script provided here: https://www.adaxes.com/script-repository/move-mailbox-tofrom-microsoft-365-s579.htm Unfortuntately when executing ... credentials but I do not know why this error is happening. Thanks in advance

asked Aug 1 by curtisa (150 points)
0 votes
1 answer

Hi, I am looking to build a report whereby all users within a specific OU (Disabled and forwarding). The report will return users who have been inactive for 90 days along with ... do this. Could someone give me the script to be able to do this please? Thanks!

asked Dec 20, 2022 by gareth.aylward (180 points)
+1 vote
1 answer

Hello All, it is possible to configure SMTP mail setting using Exchange Online with modern authentication and Azure security defaults enabled? Currently I have setup local IIS ... defaults but I would like to connect to my more secured tenant. Regards Ivaylo

asked Dec 6, 2022 by ivaylo.valkov (100 points)
0 votes
1 answer

Recently, Microsoft deprecated use of the remote PS sessions using version 1. We have since converted all of our scripts to version 2, but our nightly staff ... { # Close the remote session and release resources Disconnect-ExchangeOnline -Confirm:$false }

asked Nov 2, 2022 by MShep (60 points)
0 votes
0 answers

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

asked Jul 13, 2022 by RayBilyk (230 points)
3,175 questions
2,878 answers
7,369 comments
507,161 users