-
Notifications
You must be signed in to change notification settings - Fork 239
/
Copy patho365-malware-policy.ps1
54 lines (39 loc) · 1.74 KB
/
o365-malware-policy.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<# CIAOPS
Script provided as is. Use at own risk. No guarantees or warranty provided.
Description - Configure a new Exchange Online malware filtering policy
Source - https://github.com/directorcia/Office365/blob/master/o365-malware-policy.ps1
Prerequisites = 1
1. Ensure Exchange online PowerShell module installed or updated
More scripts available by joining http://www.ciaopspatron.com
#>
## Variables
$systemmessagecolor = "cyan"
$processmessagecolor = "green"
## Separate multiple domains with comma (,) e.g."domain1.com", "domain2.com", "domain3.com"
$domains = "M365B555418.onmicrosoft.com"
$policyname = "Configured Policy"
$rulename = "Configured Recipients"
## If you have running scripts that don't have a certificate, run this command once to disable that level of security
## set-executionpolicy -executionpolicy bypass -scope currentuser -force
Clear-Host
write-host -foregroundcolor $systemmessagecolor "Script started`n"
write-host -foregroundcolor $processmessagecolor "Set new malware policy"
$policyparams = @{
"Name" = $policyname;
'Action' = 'deletemessage';
'Enablefilefilter' = $true;
'Enableinternalsendernotifications' = $true;
'Zap' = $true
}
new-malwarefilterpolicy @policyparams
write-host -foregroundcolor $processmessagecolor "Set new malware filter rule"
$ruleparams = @{
'name' = $rulename;
'comments' = 'This is a custom policy added via a PowerShell script';
'malwarefilterpolicy' = $policyname; ## this needs to match the above policy name
'recipientdomainis' = $domains; ## this needs to match the domains you wish to protect in your tenant
'Priority' = 0;
'Enabled' = $true
}
New-malwarefilterrule @ruleparams
write-host -foregroundcolor $systemmessagecolor "Script complete`n"