Skip to content

Commit

Permalink
Merge pull request KelvinTegelaar#385 from DChorn-ANS/patch-7
Browse files Browse the repository at this point in the history
User Submission Button standard
  • Loading branch information
KelvinTegelaar authored Jul 21, 2023
2 parents 0726fdd + 4bde4e6 commit 9aa6a77
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Standards_UserSubmissions/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bindings": [
{
"name": "tenant",
"direction": "in",
"type": "activityTrigger"
}
]
}
44 changes: 44 additions & 0 deletions Standards_UserSubmissions/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
param($tenant)

$ConfigTable = Get-CippTable -tablename 'standards'
$Setting = ((Get-AzDataTableEntity @ConfigTable -Filter "PartitionKey eq 'standards' and RowKey eq '$tenant'").JSON | ConvertFrom-Json).standards.usersubmissions
if (!$Setting) {
$Setting = ((Get-AzDataTableEntity @ConfigTable -Filter "PartitionKey eq 'standards' and RowKey eq 'AllTenants'").JSON | ConvertFrom-Json).standards.usersubmissions
}
if ($Setting.enable -and $Setting.disable) {
Write-LogMessage -API "Standards" -tenant $tenant -message "You cannot both enable and disable the User Submission policy" -sev Error
Exit
}
elseif ($setting.enable) {
$status = $true
try {
$Policy = New-ExoRequest -tenantid $Tenant -cmdlet "Get-ReportSubmissionPolicy"
if ($Policy.length -eq 0) {
New-ExoRequest -tenantid $Tenant -cmdlet "New-ReportSubmissionPolicy"
Write-LogMessage -API "Standards" -tenant $tenant -message "User Submission policy set to $status." -sev Info
}
else {
New-ExoRequest -tenantid $Tenant -cmdlet "Set-ReportSubmissionPolicy" -cmdParams @{ EnableReportToMicrosoft = $status; Identity = $($Policy.Identity); }
Write-LogMessage -API "Standards" -tenant $tenant -message "User Submission policy set to $status." -sev Info
}
}
catch {
Write-LogMessage -API "Standards" -tenant $tenant -message "Could not set User Submission policy to $status. Error: $($_.exception.message)" -sev Error
}
}
else {
$status = $false
try {
$Policy = New-ExoRequest -tenantid $Tenant -cmdlet "Get-ReportSubmissionPolicy"
if ($Policy.length -eq 0) {
Write-LogMessage -API "Standards" -tenant $tenant -message "User Submission policy set to $status." -sev Info
}
else {
New-ExoRequest -tenantid $Tenant -cmdlet "Set-ReportSubmissionPolicy" -cmdParams @{ EnableReportToMicrosoft = $status; Identity = $($Policy.Identity); EnableThirdPartyAddress = $status; ReportJunkToCustomizedAddress = $status; ReportNotJunkToCustomizedAddress = $status; ReportPhishToCustomizedAddress = $status; }
Write-LogMessage -API "Standards" -tenant $tenant -message "User Submission policy set to $status." -sev Info
}
}
catch {
Write-LogMessage -API "Standards" -tenant $tenant -message "Could not set User Submission policy to $status. Error: $($_.exception.message)" -sev Error
}
}

0 comments on commit 9aa6a77

Please sign in to comment.