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

Hi Jennifer,

 

Yes, I did locate the scripts and make a copy. So, I'm good there... thanks.

 

I also figured out how to copy an out of the box action and attach the copied scripts. Just so I'm working with copied and not disturbing the originals. 

 

My ultimate goal here is to go beyond the out of box actions of the EXO Online spoke like Sam did above.

Ok, cool.  Yes, we would like to be able to go beyond what they have, we have done that with Active Directory items, but are struggling just to get ServiceNow to connect to MS Exchange Online.

Can you share how you were able to do this with a workflow?  I am trying to grant employees access to a mailbox and we are having a HORRIBLE time getting the MS Exchange Online Spoke setup.  I am looking for other options like rest calls. 

 

SN Support told us to try running the scripts on the MID server with our service account to be sure they run, but I have had no luck.  Any suggestions?

Ha, yes. I've been doing a lot of research on this as well. I have not been able to get this working as of yet. I've been able to set other things like setting out of office for a user (one of the out of the box options) via flow. 

We went through the entire spoke setup process to setup the OAuth 2 credentials - 

https://docs.servicenow.com/en-US/bundle/tokyo-application-development/page/administer/integrationhu...

and this is how actions like setting out off office are working for us. If you look closely at this action, it's making a REST call via Microsoft Graph. Unfortunately, there is not REST API in Graph for setting mailbox permissions. It just does not exist yet, but it sounds like it's coming. 

So, that's why the EXO spoke is using PowerShell in certain actions. It's the only route.Rather than focusing on permissions I decided to attempt any of the out of box actions that user EXO PowerShell. Just to make sure I can make one work. I'm currently testing the create mailbox action but running into the same issue as you. The required windows credentials are failing. Support just told me the same thing, that the service account credentials need access to the MID server. Been going back and forth for weeks on this ticket 😞

I'll be sure to update this thread one I figure out both the credential issue and the assigning permissions goal.

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.