Exchange Online PowerShell V2 Copy “Sent As” Message to the original mailbox

The estimated reading time 3 minutes

I decided to write this article about ” Sent as” permission because lots of myths and false assumptions are connected with this topic.
Many organizations use this feature to reply and veil their personal mail address. This is quite the right way.
Now the issue ( many people don’t know there is a issue 😉 ). If a user who has “send as” permissions (assistant) sends a mail as another mailbox (manager) the outgoing mails will not stored in the manager mailbox (by default) you have to configure this.
In most cases people recognize this “feature” with shared mailboxes where multiple people work together and they don’t see what the other sent.
Here original Microsoft article.

To activate this feature you have to connect via PowerShell to your Exchange Online environment. See the pure command to activate cop mode.

Set-Mailbox sharedmailbox@it-koehler.com -MessageCopyForSendOnBehalfEnabled $true

After setup for this mailbox every message “send as” is copied in the “sent items” folder by exchange online.

But wait; who can we connect to exchange online via PowerShell? Some time ago there was a major change for EX Online PowerShell, Exchange Online PowerShell V2 was released.

For instructions to install and use see this microsoft article
Here is my short setup to install and connect to EX Online with Module V2:

Install-Module -Name ExchangeOnlineManagement -Scope AllUsers -Verbose -Force
Import-Module -Name ExchangeOnlineManagement -Verbose
Get-Module ExchangeOnlineManagement
$creds = Get-Credential
Connect-ExchangeOnline -Credential $creds 

After connecting successful to EX Online you can use the new cmdlets.

#see all mailboxes with reduced properties
Get-EXOMailbox
#see all mailboxes with "all" properties 
Get-EXOMailbox -PropertySets All
#get all mailboxes and see where MessageCopy is enabled
Get-EXOMailbox -PropertySets Delivery | fl *userprin*,*copy*

If you’d like to know little bit more about PropertySets see this Link.

As mentioned mostly shared mailboxes need this feature and if you have tons of them, it may be painful to set CopyMessage to ALL of them manually.
My little script can do exactly this. I’ve added some outpout in PowerShell console so you have better control on how the script does its job.

script:

Example Output from script
#getting all shared mailboxes and related properties
$sharedmailboxes = Get-EXOMailbox -PropertySets Delivery -Properties RecipientTypeDetails  | Where-Object{$_.RecipientTypeDetails -eq "SharedMailbox"}  | Sort-Object UserPrincipalName
#modify every shared mailbox
foreach($mb in $sharedmailboxes){
  $upn = ($mb).UserprincipalName
  Write-Host "$upn MessageCopySentAs before modification:" $mb.MessageCopyForSentAsEnabled -ForegroundColor Yellow
  Write-Host "$upn MessageCopyForSendOnBehalf before modification:" $mb.MessageCopyForSendOnBehalfEnabled  -ForegroundColor Yellow
  Write-Host "Changing MessageCopySentAs and MessageCopySendOnBehalf for user $upn " -ForegroundColor Cyan
  #setup the mailbox for copy enabled
  Set-Mailbox -Identity $upn -MessageCopyForSentAsEnabled $true -MessageCopyForSendOnBehalfEnabled $true
  #check if set correctly
  $changeduser = Get-EXOMailbox -PropertySets Delivery -Identity $upn
  $messagecopysentas = ($changeduser).MessageCopyForSentAsEnabled
  $messagecopysendonbehalf = ($changeduser).MessageCopyForSendOnBehalfEnabled 
  #check if messagecopy sentas is set to true
    if($messagecopysentas){
      Write-Host "User $upn MessageCopyForSentAsEnabled is set to $messagecopysentas" -ForegroundColor Green
    }
    else{
      Write-Host "error:User $upn MessageCopyForSentAsEnabled is set to $messagecopysentas, please try manually" -ForegroundColor Red 
    }
  #check if messagecopy sendonbehalf is set to true
    if($messagecopysendonbehalf){
      Write-Host "User $upn MessageCopyForSendOnBehalf is set to $messagecopysendonbehalf" -ForegroundColor Green
    }
    else{
      Write-Host "error:User $upn MessageCopyForSendOnBehalf is set to $messagecopysendonbehalf, please try manually" -ForegroundColor Red 
    }
}

So it searches for shared mailboxes only and sets parameters
MessageCopyForSentAsEnabled $true
MessageCopyForSendOnBehalfEnabled $true

After setup it checks if the settings are correct and if an error in powershell console is displayed. Soon there will be a new article about Exchange Online PowerShell V2 usecases. Stay tuned and if you liked this article please click on “helpful”. If you have any questions, let me know in comment section.

Print Friendly, PDF & Email
Was this article helpful?
YesNo
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments