forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from KelvinTegelaar/master
[pull] master from KelvinTegelaar:master
- Loading branch information
Showing
13 changed files
with
617 additions
and
574 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
98 changes: 48 additions & 50 deletions
98
Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAtpPolicyForO365.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,48 @@ | ||
function Invoke-CIPPStandardAtpPolicyForO365 { | ||
<# | ||
.FUNCTIONALITY | ||
Internal | ||
#> | ||
|
||
param($Tenant, $Settings) | ||
$AtpPolicyForO365State = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AtpPolicyForO365' | | ||
Select-Object EnableATPForSPOTeamsODB, EnableSafeDocs, AllowSafeDocsOpen | ||
|
||
$StateIsCorrect = if ( | ||
($AtpPolicyForO365State.EnableATPForSPOTeamsODB -eq $true) -and | ||
($AtpPolicyForO365State.EnableSafeDocs -eq $true) -and | ||
($AtpPolicyForO365State.AllowSafeDocsOpen -eq $Settings.AllowSafeDocsOpen) | ||
) { $true } else { $false } | ||
|
||
if ($Settings.remediate -eq $true) { | ||
if ($StateIsCorrect -eq $true) { | ||
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Atp Policy For O365 already set.' -sev Info | ||
} else { | ||
$cmdparams = @{ | ||
EnableATPForSPOTeamsODB = $true | ||
EnableSafeDocs = $true | ||
AllowSafeDocsOpen = $Settings.AllowSafeDocsOpen | ||
} | ||
|
||
try { | ||
New-ExoRequest -tenantid $Tenant -cmdlet 'Set-AntiPhishPolicy' -cmdparams $cmdparams | ||
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Updated Atp Policy For O365' -sev Info | ||
} catch { | ||
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message | ||
Write-LogMessage -API 'Standards' -tenant $Tenant -message "Failed to set Atp Policy For O365. Error: $ErrorMessage" -sev Error | ||
} | ||
} | ||
} | ||
|
||
if ($Settings.alert -eq $true) { | ||
|
||
if ($StateIsCorrect -eq $true) { | ||
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Atp Policy For O365 is enabled' -sev Info | ||
} else { | ||
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Atp Policy For O365 is not enabled' -sev Alert | ||
} | ||
} | ||
|
||
if ($Settings.report -eq $true) { | ||
Add-CIPPBPAField -FieldName 'AtpPolicyForO365' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $tenant | ||
} | ||
|
||
} | ||
function Invoke-CIPPStandardAtpPolicyForO365 { | ||
<# | ||
.FUNCTIONALITY | ||
Internal | ||
#> | ||
|
||
param($Tenant, $Settings) | ||
$CurrentState = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AtpPolicyForO365' | | ||
Select-Object EnableATPForSPOTeamsODB, EnableSafeDocs, AllowSafeDocsOpen | ||
|
||
$StateIsCorrect = ($CurrentState.EnableATPForSPOTeamsODB -eq $true) -and | ||
($CurrentState.EnableSafeDocs -eq $true) -and | ||
($CurrentState.AllowSafeDocsOpen -eq $Settings.AllowSafeDocsOpen) | ||
|
||
if ($Settings.remediate -eq $true) { | ||
if ($StateIsCorrect -eq $true) { | ||
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Atp Policy For O365 already set.' -sev Info | ||
} else { | ||
$cmdparams = @{ | ||
EnableATPForSPOTeamsODB = $true | ||
EnableSafeDocs = $true | ||
AllowSafeDocsOpen = $Settings.AllowSafeDocsOpen | ||
} | ||
|
||
try { | ||
New-ExoRequest -tenantid $Tenant -cmdlet 'Set-AtpPolicyForO365' -cmdparams $cmdparams -UseSystemMailbox $true | ||
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Updated Atp Policy For O365' -sev Info | ||
} catch { | ||
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message | ||
Write-LogMessage -API 'Standards' -tenant $Tenant -message "Failed to set Atp Policy For O365. Error: $ErrorMessage" -sev Error | ||
} | ||
} | ||
} | ||
|
||
if ($Settings.alert -eq $true) { | ||
|
||
if ($StateIsCorrect -eq $true) { | ||
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Atp Policy For O365 is enabled' -sev Info | ||
} else { | ||
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Atp Policy For O365 is not enabled' -sev Alert | ||
} | ||
} | ||
|
||
if ($Settings.report -eq $true) { | ||
Add-CIPPBPAField -FieldName 'AtpPolicyForO365' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $tenant | ||
} | ||
|
||
} |
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
Oops, something went wrong.