To grant full access to an Microsoft 365 Mailbox you must first connect to the remote PowerShell, and provide MailboxPermission.
PS C:\WINDOWS\system32> Import-Module MSOnline
For admin accounts without multifactor authentication, use the Get-Credential method.
### create credential object and specify admin credentials
PS C:\WINDOWS\system32> $Credential = Get-Credential
### build session
PS C:\WINDOWS\system32> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic –AllowRedirection
### import into PowerShell session
PS C:\WINDOWS\system32> Import-PSSession $Session
### user.x is the mailbox that you want grant access to user.y
PS C:\WINDOWS\system32> Add-MailboxPermission –Identity “[email protected]” –User “[email protected]” –AccessRights FullAccess
Identity – user or shared mailbox to be given permission
User – User that will get permission
AccessRights – permissions either FullAccess, SendAs …etc
Note: If incase you experience script execution error with Import-PSSession, then follow our article for a solution – Error while importing PSSession on Microsoft365