Skip to content

Commit

Permalink
Merge pull request #8 from KelvinTegelaar/master
Browse files Browse the repository at this point in the history
[pull] master from KelvinTegelaar:master
  • Loading branch information
pull[bot] authored Oct 9, 2023
2 parents 2f09709 + ddce568 commit 6ac223c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions ExecNotificationConfig/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $results = try {
'webhook' = "$($Request.Body.Webhook)"
'onePerTenant' = [boolean]$Request.Body.onePerTenant
'sendtoIntegration' = [boolean]$Request.Body.sendtoIntegration
'includeTenantId' = [boolean]$Request.Body.includeTenantId
'PartitionKey' = 'CippNotifications'
'RowKey' = 'CippNotifications'
}
Expand Down
8 changes: 7 additions & 1 deletion GraphHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function Get-GraphToken($tenantid, $scope, $AsApp, $AppID, $refreshToken, $Retur
}
}

function Write-LogMessage ($message, $tenant = 'None', $API = 'None', $user, $sev) {
function Write-LogMessage ($message, $tenant = 'None', $API = 'None', $tenantId = $null, $user, $sev) {
try {
$username = ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($user)) | ConvertFrom-Json).userDetails
}
Expand All @@ -143,6 +143,12 @@ function Write-LogMessage ($message, $tenant = 'None', $API = 'None', $user, $se
'PartitionKey' = $PartitionKey
'RowKey' = ([guid]::NewGuid()).ToString()
}

if($tenantId)
{
$TableRow.Add('TenantID', [string]$tenantId)
}

$Table.Entity = $TableRow
Add-AzDataTableEntity @Table | Out-Null
}
Expand Down
2 changes: 1 addition & 1 deletion ListNotificationConfig/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if ($Config) {
$Config = @{}
}
#$config | Add-Member -NotePropertyValue @() -NotePropertyName 'logsToInclude' -Force
$config.logsToInclude = @(([pscustomobject]$config | Select-Object * -ExcludeProperty schedule, type, tenantid, onepertenant, sendtoIntegration, partitionkey, rowkey, tenant, ETag, email, logsToInclude, Severity, Alert, Info, Error, timestamp, webhook).psobject.properties.name)
$config.logsToInclude = @(([pscustomobject]$config | Select-Object * -ExcludeProperty schedule, type, tenantid, onepertenant, sendtoIntegration, partitionkey, rowkey, tenant, ETag, email, logsToInclude, Severity, Alert, Info, Error, timestamp, webhook, includeTenantId).psobject.properties.name)
if (!$config.logsToInclude) {
$config.logsToInclude = @('None')
}
Expand Down
10 changes: 9 additions & 1 deletion Scheduler_Alert/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ try {
}
$Alerts = Get-AzDataTableEntity @Table -Filter $Filter

$ConfigFilter = "RowKey eq 'CippNotifications' and PartitionKey eq 'CippNotifications'"
$Config = [pscustomobject](Get-AzDataTableEntity @Table -Filter $ConfigFilter)

$DeltaTable = Get-CIPPTable -Table DeltaCompare
$LastRunTable = Get-CIPPTable -Table AlertLastRun

Expand Down Expand Up @@ -378,7 +381,12 @@ try {

$ShippedAlerts | ForEach-Object {
if ($_ -notin $currentlog.Message) {
Write-LogMessage -message $_ -API 'Alerts' -tenant $tenant.tenant -sev Alert
if ($Config.includeTenantId) {
Write-LogMessage -message $_ -API 'Alerts' -tenant $tenant.tenant -sev Alert -tenantid $Tenant.tenantid
}
else {
Write-LogMessage -message $_ -API 'Alerts' -tenant $tenant.tenant -sev Alert
}
}
}
[PSCustomObject]@{
Expand Down

0 comments on commit 6ac223c

Please sign in to comment.