Remove automapping for a shared mailbox in Office 365

$Credential = Get-Credential
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid" -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $ExchangeSession
Remove-MailboxPermission -Identity shared.mail@example.com -User user.mail@example.com -AccessRights FullAccess
Add-MailboxPermission -Identity shared.mail@example.com -User user.mail@example.com -AccessRight FullAccess -InheritanceType All -Automapping $false

Remove and re-add multiple users to a shared mailbox with full access and without automapping

##################################################
# Login to Exchange
##################################################

$Credential = Get-Credential
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid" -Credential $credential -Authentication "Basic" -AllowRedirection

##################################################
# Remove and re-add user to shared mailbox with 
# "Full Access" without automapping enabled
##################################################

# Enter all the users here
$users = @( "<email-1@example.com>"; "<email-2@example.com>"; "<email-3@example.com>" )

# Enter the shared mailbox here
$sharedmail = "<shared_email@example.com>"

# Run the operation
Import-PSSession $ExchangeSession
$users | % {Remove-MailboxPermission -Identity $sharedmail -User $_ -AccessRights FullAccess -Confirm:$false}
$users | % {Add-MailboxPermission -Identity $sharedmail -User $_ -AccessRight FullAccess -InheritanceType All -Automapping $false}
$users | % {Add-RecipientPermission $sharedmail -AccessRights SendAs -Trustee $_ -Confirm:$false}

# Adds "Copy items sent as this mailbox" and "Copy items sent on behalf of this mailbox" for the shared mail box
Set-Mailbox $sharedmail -MessageCopyForSentAsEnabled $True
Set-Mailbox $sharedmail -MessageCopyForSendOnBehalfEnabled $True

Get-PSSession | Remove-PSSession

Sources:

https://support.microsoft.com/en-us/help/2646504/how-to-remove-automapping-for-a-shared-mailbox-in-office-365

https://o365info.com/mailbox-permissions-powershell-commands/