You can block it directly in Entra ID/M365 admin portal.
Shared Mailbox Sign in block
Sanjay Bhakuni - admin
125
Reputation points
We have shared mailboxes synced with AD. Can we block their sign in from office 365 or do we need to disable them from AD to block their sign in.