All you want to do is delete a Shared Mailbox in Exchange Online. But it is stupidly stubborn. It doesn’t want to delete. All you get is
Remove-Mailbox: The following error occurred during validation in agent ‘Windows LiveId Agent’: ‘Unable to perform the save operation. ‘SharedMailboxName’ is not within a valid server write scope.’
SOLUTION: Delete the related Azure AD user account. In the following example, I removed related MSOL user account, that also removes the shared mailbox.
Get-MsolUser -UserPrincipalName email@example.com | Remove-MsolUser -Force
You can also use AzureAD PowerShell cmdlet or Azure AD console in Azure to remove the user account.