Thursday, 21 January 2016

Set Send As Permission Office 365 using Powershell

We can set or grant send as permission for an office 365 mailbox using the powershell cmdlet Add-RecipientPermission .

Note: Before proceed, Connect Exchange Online Remote PowerShell.

Run the following command to grant send as permission to Morgan on the user Kevin’s mailbox.
Add-RecipientPermission Kevin -Trustee Morgan -AccessRights SendAs -Confirm:$False
Trustee - The mailbox that should be granted the send as permission.

Set Send As Permissions for Bulk Mailboxes from Text file

Use the below powershell script to configure Send As permission for bulk office 365 mailboxes from text file. First create the text file Mailboxes.txt which includes one mailbox in each line.
Get-Content C:\Mailboxes.txt | ForEach-Object{
 $mailbox = $_
 Add-RecipientPermission $mailbox -Trustee <user> -AccessRights SendAs -Confirm:$False
}

Set Send As Access for Multiple Users and Multiple Trustee from CSV file

We may required to grant Send As access for multiple users in multiple users' mailbox, in this case we can have mailbox and trustee names in csv file. Consider the csv file "MailboxTrusteeDetails.csv" that has two column headers "TargetMailbox" and "Trustee".

Your CSV file should include the details in below format.
TargetMailbox,Trustee
MailboxUser1,TrusteeUser1
MailboxUser1,TrusteeUser2
MailboxUser2,TrusteeUser3
MailboxUser2,TrusteeUser4
Run the following commands to import details from CSV file and add Send As permission.
Import-Csv 'C:\MailboxTrusteeDetails.csv' | ForEach-Object{
$mailbox = $_."TargetMailbox"
$trustee = $_."Trustee"
Add-RecipientPermission $mailbox -Trustee $trustee -AccessRights SendAs -Confirm:$False
}

Grant Send As access to all Mailboxes in Office 365

Use the below powershell script to configure send as permission for all the mailbox users in your Office 365.
$MBXS = Get-Recipient -RecipientType UsermMilbox 
ForEach ($MBX in $MBXS) 
{ 
Add-RecipientPermission $MBX.name -AccessRights SendAs –Trustee <user> -Confirm:$False 
} 

List all send as permissions

If you want to list all the configured send as permissions, use the below command.
Get-RecipientPermission | Where {($_.Trustee -ne 'nt authority\self') -and ($_.Trustee -ne 'null sid')}

Advertisements
Advertisements

2 comments:

  1. how do you do this from csv with multiple users, each with multiple trustees?

    ReplyDelete
    Replies
    1. Hi Zim, I have added script to update Send As access for multiple users in multiple users' mailbox. You can refer the sectiion "Set Send As Access for Multiple Users and Multiple Trustee from CSV file" in above post.

      You can create csv file (ex: "MailboxTrusteeDetails.csv") which has two column headers "TargetMailbox" and "Trustee".

      Your CSV file should have details in below format.

      TargetMailbox,Trustee
      MailboxUser1,TrusteeUser1
      MailboxUser1,TrusteeUser2
      MailboxUser2,TrusteeUser3
      MailboxUser2,TrusteeUser4

      Then run the following commands

      Import-Csv 'C:\MailboxTrusteeDetails.csv' | ForEach-Object{
      $mailbox = $_."TargetMailbox"
      $trustee = $_."Trustee"
      Add-RecipientPermission $mailbox -Trustee $trustee -AccessRights SendAs -Confirm:$False
      }

      Delete