Get-MailboxPermission always looks at on-prem DC versus EXO

Copper Contributor

Running Powershell 5.1 on a Windows VM with Exchange Management Shell v15 installed, along with 2.0.6 of the EXO PoSh module.

 

I'm trying to add permissions to a shared mailbox in Exchange Online. I load the modules, Connect-ExchangeOnline, and run Get-MailboxPermission -identity $mailbox. I never use the -domaincontroller switch. The cmdlet always returns that it cannot find the mailbox on one of the on-prem domain controllers.

 

I must be doing something wrong, but not sure what. How do I get this to only look in EXO? Any advice is greatly appreciated, and thanks in advance!

5 Replies
Use regular PowerShell to connect to ExO, instead of the EMS? This should prevent session overlap. Adding a session prefix is another option.

@Vasil Michev Thank you for the quick reply! Would you mind explaining a little more--not sure I follow. Should have mentioned that I'm not an Exchange admin. It would seem that Exchange cmdlets like this that can run in both on prem and EXO would have a switch to indicate which environment it should run in. 

They don't have a switch, the cmdlets names are the same, with some differences in parameters. Thus if you already have a session opened against your Exchange server (happens by default when you launch the EMS) and connect to Exchange Online, you're effectively duplicating (most of) the cmdlets. You can use the Connect-ExchangeOnline with the -Prefix parameter, or simply open a regular PowerShell console and connect from there.
Thank you again for your time and patience! -Prefix sounds like the solution. Unfortunately, it does not work. Here's what the script does. Not sure what I'm doing wrong:

1. Load Exchange Management PSSnapin
2. Create shared mailbox on-prem using New-RemoteMailbox, then Set-RemoteMailbox to add properties
3. Create distribution group on-prem using New-DistributionGroup, then Set-DistributionGroup to add properties
4. Wait for sync to O365, then connect to Exchange Online
5. Run Add-MailboxPermission and Add-RecipientPermission against the shared mailbox in O365

When connecting to EXO, I used Connect-ExchangeOnline -Prefix "DVO" and authenticated via the UI. I then verify I'm in with Get-EXOMailbox. I then tried Get-DVOMailboxPermission. Cmdlet not found is returned.
Also--I see MSFT updated their EXO V2 documentation on 8/3. It documented a Get-EXOMailboxPermission cmdlet, which is a REST wrapper for Get-MailboxPermission. I ran it in debug after connecting to EXO and it returned a 401.

This may ultimately be a permissions issue.