-
Notifications
You must be signed in to change notification settings - Fork 0
/
whitelist_o365_exchange.ps1
30 lines (23 loc) · 1.29 KB
/
whitelist_o365_exchange.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$globaladmin = "[email protected]"
$credentials = Get-Credential -Credential $globaladmin
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credentials -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking
$domainlist = Read-Host -Prompt 'Domain(s) to add to Allow list (press ENTER if none, use single space between entries)'
$addresslist = Read-Host -Prompt 'Email(s) to add to Allow list (press ENTER if none, use single space between entries)'
$domains = $domainlist -split " "
$addresses = $addresslist -split " "
if (!$domainlist) {
Write-Host "No domains to add...skipping"
} else {
Write-Host "Adding domain name(s) to Company Main Spam Policy Allow list...."
Set-HostedContentFilterPolicy -Identity "Company Main Spam Policy" -AllowedSenderDomains @{Add=$domains}
}
if (!$addresslist) {
Write-Host "No addresses to add...skipping"
} else {
Write-Host "Adding email address(es) to Company Main Spam Policy Allow list...."
Set-HostedContentFilterPolicy -Identity "Company Main Spam Policy" -AllowedSenders @{Add=$addresses}
}
Write-Host -NoNewLine 'Press any key to continue...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
Remove-PSSession $Session