Office 365 – Shared Mailbox – Sent email not saving in shared “Sent Items”

Shared mailboxes migrated just fine into Office 365 (Exchange Online) shared mailboxes.  Users that are able to send email on behalf of the shared mailbox are having the sent email copy stored in the “Sent Items” of the sender as opposed to the “Sent Items” of the shared mailbox.  All the people who share use of the shared mailbox would like to be able to see sent email by others using the  shared mailbox.

Microsoft decided that this should be an ability of Exchange Online, but did not set that behavior by default. Please refer to this TechNet article for more details on how to set this behavior.

I needed a script that would be able to march through all the shared mailboxes and make the change.  Here’s the script:

$sharedMailboxCollection = Get-Mailbox -Filter {RecipientTypeDetails -eq 'SharedMailbox'}
foreach ($mailBox in $sharedMailboxCollection)
 {
 $mailBox.UserPrincipalName
 set-mailbox $mailBox.UserPrincipalName -MessageCopyForSentAsEnabled $True
 set-mailbox $mailBox.UserPrincipalName -MessageCopyForSendOnBehalfEnabled $True
 }