Skip to content

Commit

Permalink
alert mods
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Aug 10, 2023
1 parent 7d7eb0b commit 0dc8bcb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 34 deletions.
57 changes: 29 additions & 28 deletions AddAlert/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,36 @@ $Results = foreach ($Tenant in $tenants) {
else {
'AllTenants'
}
$CompleteObject = @{
tenant = $tenant
tenantid = $TenantID
AdminPassword = [bool]$Request.body.AdminPassword
DefenderMalware = [bool]$Request.body.DefenderMalware
DefenderStatus = [bool]$Request.body.DefenderStatus
MFAAdmins = [bool]$Request.body.MFAAdmins
MFAAlertUsers = [bool]$Request.body.MFAAlertUsers
NewGA = [bool]$Request.body.NewGA
NewRole = [bool]$Request.body.NewRole
QuotaUsed = [bool]$Request.body.QuotaUsed
UnusedLicenses = [bool]$Request.body.UnusedLicenses
OverusedLicenses = [bool]$Request.body.OverusedLicenses
AppSecretExpiry = [bool]$Request.body.AppSecretExpiry
ApnCertExpiry = [bool]$Request.body.ApnCertExpiry
VppTokenExpiry = [bool]$Request.body.VppTokenExpiry
DepTokenExpiry = [bool]$Request.body.DepTokenExpiry
NoCAConfig = [bool]$Request.body.NoCAConfig
SecDefaultsUpsell = [bool]$Request.body.SecDefaultsUpsell
SharePointQuota = [bool]$Request.body.SharePointQuota
ExpiringLicenses = [bool]$Request.body.ExpiringLicenses
type = 'Alert'
RowKey = $TenantID
PartitionKey = 'Alert'
}

$Table = get-cipptable -TableName 'SchedulerConfig'
Add-AzDataTableEntity @Table -Entity $CompleteObject -Force
if ($Request.body.SetAlerts) {
$CompleteObject = @{
tenant = $tenant
tenantid = $TenantID
AdminPassword = [bool]$Request.body.AdminPassword
DefenderMalware = [bool]$Request.body.DefenderMalware
DefenderStatus = [bool]$Request.body.DefenderStatus
MFAAdmins = [bool]$Request.body.MFAAdmins
MFAAlertUsers = [bool]$Request.body.MFAAlertUsers
NewGA = [bool]$Request.body.NewGA
NewRole = [bool]$Request.body.NewRole
QuotaUsed = [bool]$Request.body.QuotaUsed
UnusedLicenses = [bool]$Request.body.UnusedLicenses
OverusedLicenses = [bool]$Request.body.OverusedLicenses
AppSecretExpiry = [bool]$Request.body.AppSecretExpiry
ApnCertExpiry = [bool]$Request.body.ApnCertExpiry
VppTokenExpiry = [bool]$Request.body.VppTokenExpiry
DepTokenExpiry = [bool]$Request.body.DepTokenExpiry
NoCAConfig = [bool]$Request.body.NoCAConfig
SecDefaultsUpsell = [bool]$Request.body.SecDefaultsUpsell
SharePointQuota = [bool]$Request.body.SharePointQuota
ExpiringLicenses = [bool]$Request.body.ExpiringLicenses
type = 'Alert'
RowKey = $TenantID
PartitionKey = 'Alert'
}

$Table = get-cipptable -TableName 'SchedulerConfig'
Add-AzDataTableEntity @Table -Entity $CompleteObject -Force
}
$URL = ($request.headers.'x-ms-original-url').split('/api') | Select-Object -First 1
if ($Tenant -eq 'AllTenants') {
Get-Tenants | ForEach-Object {
Expand Down
8 changes: 5 additions & 3 deletions Scheduler_CIPPNotifications/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ $Config = [pscustomobject](Get-AzDataTableEntity @Table -Filter $Filter)
$Settings = [System.Collections.ArrayList]@('Alerts')
$Config.psobject.properties.name | ForEach-Object { $settings.add($_) }
$severity = $Config.Severity -split ','
Write-Host "Our Severity table is: $severity"
if (!$severity) {
$severity = [System.Collections.ArrayList]@('Info', 'Error', 'Warning', 'Critical', 'Alert')
}
Write-Host "Our Severity table is: $severity"
$Table = Get-CIPPTable
$PartitionKey = Get-Date -UFormat '% Y%m%d'
$Filter = "PartitionKey eq '{ 0 }'" -f $PartitionKey
$PartitionKey = Get-Date -UFormat '%Y%m%d'
$Filter = "PartitionKey eq '{0}'" -f $PartitionKey
$Currentlog = Get-AzDataTableEntity @Table -Filter $Filter | Where-Object {
$_.API -In $Settings -and $_.SentAsAlert -ne $true -and $_.Severity -In $severity
}

Write-Host ($Currentlog).count
#email try
try {
if ($config.onePerTenant) {
Expand Down
6 changes: 3 additions & 3 deletions profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# Authenticate with Azure PowerShell using MSI.
# Remove this if you are not planning on using MSI or Azure PowerShell.
Import-Module .\GraphHelper.psm1
Import-Module Az.KeyVault
Import-Module Az.Accounts
#Import-Module Az.KeyVault
#Import-Module Az.Accounts
Import-Module GraphRequests
Import-Module CippExtensions
Import-module CippCore
Import-Module CippCore

try {
Disable-AzContextAutosave -Scope Process | Out-Null
Expand Down

0 comments on commit 0dc8bcb

Please sign in to comment.