# Get user's mailbox access in Exchange online

**URL:** <https://forums.powershell.org/t/get-users-mailbox-access-in-exchange-online/14637>\
**Category:** PowerShell Help\
**Created:** [July 7, 2020, 9:56am UTC](https://forums.powershell.org/t/get-users-mailbox-access-in-exchange-online/14637 "2020-07-07T09:56:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![borg1976](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@borg1976](https://forums.powershell.org/u/borg1976)\
**Post date:** [July 7, 2020, 9:56am UTC](https://forums.powershell.org/t/get-users-mailbox-access-in-exchange-online/14637/1 "2020-07-07T09:56:28Z")

</div>

Hi all,

&nbsp;

I’m struggling with getting the following command, which worked flawlessly in Exchange On Prem, working in Exchange online:

Get-Mailbox -RecipientTypeDetails UserMailbox,SharedMailbox -ResultSize Unlimited | Get-MailboxPermission -User $user | fl identity

&nbsp;

I’ve tried

Get-ExoMailbox -RecipientTypeDetails UserMailbox,SharedMailbox -ResultSize Unlimited | Get-ExoMailboxPermission -User $user | fl identity

but it seems to be a bit more complicated than that.

&nbsp;

I’ve already got it working the other way around, getting all users with access to a specific mailbox, using the Exchange Online PowerShell V2 module, but with this I could use some help.

&nbsp;

Many thanks in advance.

&nbsp;

Borg.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [July 7, 2020, 11:03am UTC](https://forums.powershell.org/t/get-users-mailbox-access-in-exchange-online/14637/2 "2020-07-07T11:03:53Z")

</div>

Borg, can you please describe in a bit more detail what you are trying to see for your results? I am able to run the following code with the latest EXOV2 cmdlets and it works just fine. Just as a side note, unless you are calling a command specifically with EXO like Get-EXOMailbox you are still using the classic commands.

[30.36 s] C:&gt; Get-Mailbox -RecipientTypeDetails UserMailbox,SharedMailbox -ResultSize Unlimited | Get-MailboxPermission -User $user | select -First 5 | ft

Identity User AccessRights IsInherited Deny

* * *

User1 NT AUTHORITY\SELF {FullAccess, ReadPermission} False False  
User1 OnlineServer12\Administ… {FullAccess} True True  
User1 OnlineServer12\Domain A… {FullAccess} True True

User2 NT AUTHORITY\SELF {FullAccess, ReadPermission} False False  
User2 OnlineServer12\Administ… {FullAccess} True True  
User2 OnlineServer12\Domain A… {FullAccess} True True  
User2 OnlineServer12\Enterpri… {FullAccess} True True  
User2 OnlineServer12\Organiza… {FullAccess} True True  
User2 NT AUTHORITY\SYSTEM {FullAccess} True False

Dave  
User2 NT AUTHORITY\NETW… {ReadPermission} True False

---

<div class="post-metadata">

**Author:** ![borg1976](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@borg1976](https://forums.powershell.org/u/borg1976)\
**Post date:** [July 7, 2020, 8:36pm UTC](https://forums.powershell.org/t/get-users-mailbox-access-in-exchange-online/14637/3 "2020-07-07T20:36:42Z")

</div>

Hi Dave,

&nbsp;

Sure. I need the result to be something like this:

Identity : [domain.com/OU/Mailboxes/Displayname](http://domain.com/OU/Mailboxes/Displayname) Mailbox 1

Identity : [domain.com/OU/Mailboxes/Displayname](http://domain.com/OU/Mailboxes/Displayname) Mailbox 2

etc

&nbsp;

Borg

&nbsp;

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [July 8, 2020, 4:57am UTC](https://forums.powershell.org/t/get-users-mailbox-access-in-exchange-online/14637/4 "2020-07-08T04:57:11Z")

</div>

So you can do a few things here. I am just putting down the basics to show you how to get it. One way would be to do the following:

$mailboxes = Get-Mailbox - Get-Mailbox -RecipientTypeDetails UserMailbox,SharedMailbox -ResultSize Unlimited | Select-Object Identity, Alias

if you want something a bit more elegant you can create your own custom object with the following code to display whatever you want the output object to look like:

$mailboxes = Get-Mailbox - Get-Mailbox -RecipientTypeDetails UserMailbox,SharedMailbox -ResultSize Unlimited | Select-Object Identity, Alias

foreach($mbx in $mailboxs)

{

[PSCustomObject}@{

Identity = $mbx.Identity

Alias = $mbx.Alias}

“This this account disabled?” = $mbx.AccountDisabled

}

You can also use calculated properties (known as an expression) to achieve the same solution. To modify the output with calculated properties it will require a Hashtable object denoted by @{} and it will contain a Name and an Expression key. The name key is the property name that you want to use and the Expression key will be a scriptblock that is going to be executed when the Select-Object cmdlet receives input from the pipeline: Get-Mailbox - Get-Mailbox -RecipientTypeDetails UserMailbox,SharedMailbox -ResultSize Unlimited | Select-Object -Property Identity, @{Name =“DN”; Expression = {$\_.DistinugishedName}}

&nbsp;

You can keep building on to these examples to add all the rest of the data that you require. I hope this helps!

Dave

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:29pm UTC](https://forums.powershell.org/t/get-users-mailbox-access-in-exchange-online/14637/5 "2024-05-16T20:29:17Z")

</div>


