How to restrict msgrapgh access to one mailbox only

Ravindra Shukla 116 Reputation points
2021-05-12T06:28:15.477+00:00

Hi,

I am writing a powershell script using Microsoft graph to get the count of unread emails from the mailbox. I have given the applications permissions for my script to retrieve the count of unread email from the mailbox.

As I have given mail.ReadAll application permission to my script, it can access all the users mailboxes in my organization, however I want to restrict microsoft graph to one specific mailbox only, so it can access the mailbox of that user, but can't access any other users mailbox.

How can I achieve this restriction using Microsoft graph with powershell script?

Any pointers or help is appreaciated.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,645 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Vasil Michev 95,666 Reputation points MVP
    2021-05-12T06:35:45.063+00:00
    0 comments No comments

  2. Ravindra Shukla 116 Reputation points
    2021-05-12T06:59:11.53+00:00

    Hi @Vasil Michev ,

    Thank you for your reply.

    I will go through the URL mentioned by you and try it.

    0 comments No comments

  3. Ravindra Shukla 116 Reputation points
    2021-05-12T07:31:05.72+00:00

    Hi @Vasil Michev ,

    I have one more query regarding Microsoft graph.

    Can we use serviceaccount to retrieve the Microsoft O365 resources using Microsoft graph, instead of using any specific user's mailbox account ?

    Could you please share if this is possible and how to achieve this?

    Thank you.


  4. Ravindra Shukla 116 Reputation points
    2021-05-17T13:47:03.69+00:00

    @Vasil Michev One more query popped up in my mind.

    "Mail.ReadAll" application permission, as the name suggests it reads mails from all the mailboxes in the tenant.

    So it covers individual user mailboxes as well as shared mailbox, is this correct?

    Please confirm

    Thank you.