Information on how to add users to Exchange online shared mailbox using IntegrationHub Exchange online spoke?

Sam198
Mega Guru

Hi all,

I am trying to find some information/documentation on how to add user to a shared mailbox using IntegrationHub with Microsoft Exchange Online spoke - Looking at the spokes documentation, it seems that there is no ootb action such as "Add user to mailbox" to give full access or send as kind of access.

I have found the information on how to do this via Orchestration activities where you add scripts to run Exchange online powershell commands - however, using the Exchange online spoke directly connected to the Exchange online > I was hoping to see an action that could be used to just "Add user to mailbox" with appropriate permissions.

If anyone has used the spoke for doing such things - Any information or documentation on this would be helpful.

Thanks.

ServiceNow Store

find_real_file.png

1 ACCEPTED SOLUTION

Sam198
Mega Guru

Hi @Kevin Moore @Jennifer Doll @RobertR1 ,

Sorry i have not been looking at the emails recently thats why could not reply. Here is what you need to setup the add user to mailbox:

- You need EXO PS module installed on your mid server:

https://learn.microsoft.com/en-us/powershell/exchange/exchange-online-powershell-v2?view=exchange-ps

https://www.powershellgallery.com/packages/ExchangeOnlineManagement/3.0.0

- The OAuth 2.0 EOL connection is fine, you also need a credential to run PS scripts on your EOL environment - hence on the doco there is a step for Windows credential - however, i would suggest not to use basic outh username password method - Instead you need this credentials setup through a certificate - This below will help - This certificate thumbprint needs to be than added to the mid server so we can use it on the connect EXO cmd on mid server script file:

https://learn.microsoft.com/en-us/powershell/module/exchange/connect-exchangeonline?view=exchange-ps

https://office365itpros.com/2020/08/13/exchange-online-cba/

 

- Mid server script file attached - please add your certificate thumbprint, clientid, org domain - make sure your org domain is @mydomain.onmicrosoft.com.

- on the mid server script actual Add-MailboxPermission command - I have two cmd line - one for adding user to full access and second for adding user to send as access - update as per your requirement:

$mailboxname This is the variable you need to pass the mailbox email address

$user This is the variable you need to pass your user email address

 

Next the Flow custom action as below:

I only needed two input for this - add/update as you required, you can see the two variable above that i mentioned is in here and the name matches to the PS cmd in the mid server script file:

 

Sam198_4-1670023093095.png

To your question @Mark that you could not change the mid server script is because you were trying to change on the OOTB action - it does not allow on OOTB (I am guessing you have already figured this out but fyi) Below is where you add the mid server file that i have attached here.

Sam198_5-1670023093109.png

 

On this same page further down make sure you map those input variables:

Sam198_6-1670023093111.png

 

The next error handling part i am just using the ootb by changing the variables to mine.

I hope this will get your setup running.

 

Regards.

 

View solution in original post

24 REPLIES 24

Yes, it's possible. You can send API calls from ServiceNow to an Azure Runbook, which in turn executes scripts to add or remove access.

Marco Moro
Tera Guru

This topics is already more than 1.5 years ago.
As this is a topic that more and more customer are getting faced I'll opened an idea for importing e.g. Shared Mailboxes into CMDB-
Idea - Importing of Microsoft Exchange Online Mailboxes 

pranavi
Tera Contributor

Hi All , 

I tried using this information by using OOB spokes , but still i am facing error issues.
Error : PowerShell Execution Error
Requirement :
2 variables : requestedfor_email and mailbox emailaddress. Once user submits the catalog item request .user should should have full access automatically.
can someone help me please. I really need this to setup for my project.

Regards&Thanks

pranavi, I would abandon the Exchange spoke and just use a flow to run the Exchange PowerShell scripts on the MID server instead. I was using the spoke but it was a pain for 2 reasons. 1) it's limited in what it can do. Using PowerShell, you are only limited by what is possible in PowerShell. 2) When the graph secrets expire, you need to set them up again in all of your environments. 

 

Using certificates to authenticate and run your PowerShell scrips, you can simply copy the cert file to all of your MID servers. 

 

If you want to go that route let me know and we can go down that road.

 

Here's a good video on how the auth certs work - https://www.youtube.com/watch?v=GyF8HV_35GA

 

Train thousands of people, up your skills and get that next awesome job by joining TechSnips and becoming an IT rockstar! https://techsnips.io/join-us In the age of modern authentication and Exchange Online scripting, we are no longer able to use a user name and password to authenticate. If you ...

J Siva
Tera Sage

Hi@Kevin Moore 
Good day.
Reg: Level of access need to be provisioned to the Service account.
I've created a service account and granted it the required roles to read 'Distribution List' details from the Exchange server (On Prem). When I test run the custom flow action, I'm getting an access denied error.
However, if I run the script on the MID server (logged in to the mid server using my admin creds) using the same service account credential (in the powershell script Get-Credential cmdlet), I get the desired output.
Please note that the service account does not have admin access to the MID server.  So my query is, should I provision the mid server admin role to that service account ?
Could you please let me know what level of accesses need to be provisioned to the service account?

JSiva_0-1739706172438.png
Thanks,
Siva