-
Notifications
You must be signed in to change notification settings - Fork 5
/
SecureScore.ps1
86 lines (69 loc) · 3.19 KB
/
SecureScore.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Import-Module './modules/1-MailboxAuditing.psm1'
Import-Module './modules/2-BlockClientForwarding.psm1'
Import-Module './modules/3-NeverExpirePasswords.psm1'
Import-Module './modules/4-AnonymousSharingLinks.psm1'
Import-Module './modules/5-ExpireSharingLinks.psm1'
Import-Module './modules/6-AuditLogIngestion.psm1'
Import-Module './modules/7-AnonymousCalendarSharing.psm1'
Import-Module './modules/8-SharepointVersioning.psm1'
Import-Module './modules/9-SharepointIRMPolicies.psm1'
Import-Module './modules/10-ProvisionOneDrive.psm1'
Import-Module './modules/11-DataLossPrevention.psm1'
Import-Module './modules/12-AdvancedThreatProtection.psm1'
Import-Module './modules/13-DisableUserConsent.psm1'
if ((Get-Module -ListAvailable -Name MSOnline) -and (Get-Module -ListAvailable -Name Microsoft.Online.Sharepoint.Powershell)) {
} else {
Write-Host "This script requires the Microsoft Online, Microsoft Exchange, and Sharepoint Online powershell modules"
Exit
}
function Connect-Office365 {
# Get secure creds
param(
[System.Management.Automation.PSCredential]$UserCredential
)
# Microsoft Online
Connect-MsolService -Credential $UserCredential
# Exchange Online
$Session = New-PSSession -ConfigurationName Microsoft.Exchange `
-ConnectionUri https://outlook.office365.com/powershell-liveid/ `
-Credential $UserCredential -Authentication Basic -AllowRedirection
Import-Module (Import-PSSession -Session $Session -DisableNameChecking -AllowClobber) -Global
# Sharepoint Online
$Clientdomains = Get-MsolDomain | Select-Object Name
$Msdomain = $Clientdomains.name | Select-String -Pattern 'onmicrosoft.com' | Select-String -Pattern 'mail' -NotMatch
$Msdomain = $Msdomain -replace ".onmicrosoft.com",""
$SPOSite = "https://" + $Msdomain + "-admin.sharepoint.com"
Connect-SPOService -Url $SPOSite -Credential $UserCredential
# AzureAD
# Connect-AzureAD -Credential $UserCredential
}
$Credentials = Get-Credential
Connect-Office365 -UserCredential $Credentials
# modules/1-MailboxAuditing.psm1
Set-MailboxAuditing -Enabled $true
# modules/2-ClientForwardingBlock.psm1
Set-BlockClientForwarding -Enabled $true
# modules/3-NeverExpirePasswords.psm1
Set-NeverExpirePasswords -Enabled $true
# modules/4-AnonymousSharingLinks.psm1
Set-AnonymousSharingLinks -Enabled $true
# modules/5-ExpireSharingLinks.psm1
Set-ExpireSharingLinks -Enabled $true -Days 14
# modules/6-AuditLogIngestion.psm1
Set-AuditLogIngestion -Enabled $true
# modules/7-AnonymousCalendarSharing.psm1
Set-AnonymousCalendarSharing -Enabled $true
# modules/8-SharepointVersioning.psm1
Set-SharepointVersioning -Enabled $true -UserCredential $Credentials
# modules/9-SharepointIRMPolicies.psm1
Set-SharepointIRMPolicies -Enabled $true -UserCredential $Credentials -PolicyName "My IRM Policy"
# modules/10-ProvisionOneDrive.psm1
Set-ProvisionOneDrive -Enabled $true
# modules/11-DataLossPrevention.psm1
#Set-DataLossPrevention -Enabled $true -TemplateName "Canada Financial Data"
# modules/12-AdvancedThreatProtection.psm1
Set-AdvancedThreatProtection -Enabled $true
# modules/13-DisableUserConsent.psm1
# Set-DisableUserConsent -Enabled $true
Exit-Pssession
Write-Host 'Base SecureScore Configuration Is Now Completed' -ForegroundColor Green