Created
February 15, 2023 15:56
-
-
Save sikkepitje/838eee7eca0c9ad768528987c83e7026 to your computer and use it in GitHub Desktop.
PowerShell Example restricting Office 365 mail sending application to use only one sender address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
HOW TO permissie voor mail versturen beperken tot één mailbox | |
#> | |
Install-Module -Name ExchangeOnlineManagement | |
Import-Module ExchangeOnlineManagement | |
Connect-ExchangeOnline -UserPrincipalName <YOUR_USERNAME> | |
New-DistributionGroup -Name "MyEmailService" -Alias myemailservice -Type security | |
New-ApplicationAccessPolicy -AppId <YOUR_CLIENT_Id> ` | |
-PolicyScopeGroupId <YOUR_GROUPs_PRIMARY_EMAIL> -AccessRight RestrictAccess ` | |
-Description "Restrict app permissions to only allow access to service account" | |
Add-DistributionGroupMember -Identity MyEmailService ` | |
-Member <YOUR_SENDER_ADDRESS> -Confirm:$false | |
<# application access policies opvragen #> | |
Get-ApplicationAccessPolicy | |
<# application access policy verwijderen #> | |
Remove-ApplicationAccessPolicy -Identity <identiteit> | |
<# | |
Praktijkvoorbeeld | |
#> | |
New-DistributionGroup -Name "Aura Mailer App sender restriction" ` | |
-Alias Aura-Mailer-App-sender-restriction ` | |
-Type security | |
New-ApplicationAccessPolicy -AppId aabbccdd-eeff-0011-2233-445566778899 ` | |
-PolicyScopeGroupId Aura-Mailer-App-sender-restriction ` | |
-AccessRight RestrictAccess ` | |
-Description "Restrict app permissions to only allow access to service account" | |
Add-DistributionGroupMember -Identity Aura-Mailer-App-sender-restriction ` | |
-Member [email protected] -Confirm:$false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment