I have been happily using Powershell to automate a lot of admin task in an Exchange 2010 On-premises environment.
Recently, I found a new job which uses O365 in a hybrid environment. Just to explain a bit, the new environment has On-premises Active Directory plus an instance of On-premises Exchange Server (which actually has no user mailboxes inside). The On-premises Active Directory is synced to an Azure AD in the cloud and all user mailboxes are in Exchange Online in O365.
I tried to modify my Powershell script (based on On-premises Exchange 2010) to run in this new environment. I added commands to establish a MFA Powershell session to Exchange Online. Then, except replacing some On-premises Powershell commands with new cloud Powershell commands, I was able to "get-" most of the information I want.
However, when I tried to run the same Powershell commmands to update mailbox (for example to hide a mailbox), I encountered an error message saying that you cannot do so and must update via the On-premise instance. The funny thing is when I run the same old script to "add-mailboxfolderpermission" or "remove-mailboxfolderpermission", I was able to so.
Does anyone know why it is like that? If I cannot use "set-mailbox" to hide the mailbox, what commands should I use to hide the mailbox?