This script adds a single user with send-as permissons to mailboxes which are members of a single security group.
This script loops through a membership list of an Active Directory security group. A single mailbox is added to each mailbox of the security group members to provide send-as permission.
The script can be used to assign an application account (e.g. CRM, ERP) send-as permission to user mailboxes to send emails AS the user and not as the application.
- Exchange Server 2016 or newer
- Exchange Online PowerShell connection --> https://go.granikos.eu/ConnectToEXO
- Exchange Online PowerShell Module to connect w/ MFA --> https://go.granikos.eu/EXOMFA
- Utilizes GlobalFunctions PowerShell module --> http://bit.ly/GlobalFunctions
This is the name of the Active Directory security group containing all the users where the SendAsUserUpn needs to have send-as permission.
This is the UserPrincipleName of the user (service account) which will be granted send-ad permission.
Use this switch, if the target mailbox are located in Exchange Online. In this case the script must be executed from within an Exchange Online PowerShell session.
.\Set-SendAsPermission.ps1 -SendAsGroup 'CRM-FrontLine' -SendAsUserUpn 'email@example.com'
Assign Send-As permission to firstname.lastname@example.org for all members of 'CRM-FrontLine' security group. The mailboxes as hosted On-Premises!
.\Set-SendAsPermission.ps1 -SendAsGroup 'AX-Sales' -SendAsUserUpn 'email@example.com' -ExchangeOnline
Assign Send-As permission to firstname.lastname@example.org for all members of 'AX-Sales' security group. All mailboxes are hosted in Exchange Online!
THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
Download and vote at TechNet Gallery
Written by: Thomas Stensitzki
- My Blog: http://justcantgetenough.granikos.eu
- Twitter: https://twitter.com/stensitzki
- LinkedIn: http://de.linkedin.com/in/thomasstensitzki
- Github: https://github.com/Apoc70
For more Office 365, Cloud Security, and Exchange Server stuff checkout services provided by Granikos