By default, when “sending as” a shared mailbox, the sent items go into the users sent items folder. Unfortunately, it is not possible to change this to be the shared mailbox, but it is possible to put a copy in the shared mailbox’s sent items folder.
The below script will enable this for all shared mailboxes, so a copy will go into the sent items of the shared mailbox, whether the mail was sent using “send as” or “Sent on behalf”
connect-exchangeonline -UserPrincipalName
yo***********@yo**.domain
$mailboxes = get-mailbox -resultsize unlimited -RecipientTypeDetails SharedMailbox
$prog=1
foreach ($mailbox in $mailboxes){
$pct = [math]::Round((100/($mailboxes | measure-object).count) * $prog,2)
Write-Progress -Id 1 -Activity "Working on " -status "$pct % Complete:" -PercentComplete $pct -CurrentOperation $mailbox.DisplayName
write-host "trying " $mailbox.DisplayName -ForegroundColor Green
try{
set-mailbox $mailbox.displayname -MessageCopyForSentAsEnabled $True
set-mailbox $mailbox.displayname -MessageCopyForSendOnBehalfEnabled $True}
catch{
write-host "An error occured on " $mailbox.DisplayName -ForegroundColor red
}
$prog++
}