Skip to content

Commit 1316eb1

Browse files
authored
Merge pull request #613 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents b8c663a + 3219a98 commit 1316eb1

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Standards/Push-CIPPDriftManagement.ps1

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,19 @@ function Push-CippDriftManagement {
3636

3737
$GenerateEmail = New-CIPPAlertTemplate -format 'html' -data $Data -CIPPURL $CIPPURL -Tenant $Item.Tenant -InputObject 'driftStandard' -AuditLogLink $drift.standardId
3838

39-
# Send email alert if configured
40-
$CIPPAlert = @{
41-
Type = 'email'
42-
Title = $GenerateEmail.title
43-
HTMLContent = $GenerateEmail.htmlcontent
44-
TenantFilter = $Item.Tenant
39+
# Send email alert if configured and not disabled
40+
if (-not $Settings.driftAlertDisableEmail) {
41+
$CIPPAlert = @{
42+
Type = 'email'
43+
Title = $GenerateEmail.title
44+
HTMLContent = $GenerateEmail.htmlcontent
45+
TenantFilter = $Item.Tenant
46+
}
47+
Write-Information "Sending email alert for tenant $($Item.Tenant)"
48+
Send-CIPPAlert @CIPPAlert -altEmail $email
49+
} else {
50+
Write-Information "Email alert disabled for tenant $($Item.Tenant)"
4551
}
46-
Write-Information "Sending email alert for tenant $($Item.Tenant)"
47-
Send-CIPPAlert @CIPPAlert -altEmail $email
4852
# Send webhook alert if configured
4953
$WebhookData = @{
5054
Title = $GenerateEmail.title

Modules/CIPPCore/Public/Functions/Get-CIPPTenantAlignment.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ function Get-CIPPTenantAlignment {
317317
standardSettings = $Template.Standards
318318
driftAlertEmail = $Template.driftAlertEmail
319319
driftAlertWebhook = $Template.driftAlertWebhook
320+
driftAlertDisableEmail = $Template.driftAlertDisableEmail
320321
AlignmentScore = $AlignmentPercentage
321322
LicenseMissingPercentage = $LicenseMissingPercentage
322323
CombinedScore = $AlignmentPercentage + $LicenseMissingPercentage

Modules/CippEntrypoints/CippEntrypoints.psm1

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function Receive-CippHttpTrigger {
2121
if ($Request.Headers.'x-ms-coldstart' -eq 1) {
2222
Write-Information '** Function app cold start detected **'
2323
}
24+
Write-Information "CIPP_ACTION=$($Request.Params.CIPPEndpoint)"
2425

2526
$ConfigTable = Get-CIPPTable -tablename Config
2627
$Config = Get-CIPPAzDataTableEntity @ConfigTable -Filter "PartitionKey eq 'OffloadFunctions' and RowKey eq 'OffloadFunctions'"
@@ -171,7 +172,7 @@ function Receive-CippOrchestrationTrigger {
171172
Entrypoint
172173
#>
173174
param($Context)
174-
175+
Write-Information "CIPP_ACTION=$($Item.Command ?? $Item.FunctionName)"
175176
try {
176177
if (Test-Json -Json $Context.Input) {
177178
$OrchestratorInput = $Context.Input | ConvertFrom-Json
@@ -286,6 +287,7 @@ function Receive-CippActivityTrigger {
286287
Entrypoint
287288
#>
288289
param($Item)
290+
Write-Information "CIPP_ACTION=$($Item.Command ?? $Item.FunctionName)"
289291
Write-Warning "Hey Boo, the activity function is running. Here's some info: $($Item | ConvertTo-Json -Depth 10 -Compress)"
290292
try {
291293
$Output = $null
@@ -358,12 +360,8 @@ function Receive-CippActivityTrigger {
358360
}
359361

360362
try {
361-
Write-Verbose "Activity starting Function: $FunctionName."
362-
363-
# Wrap the function execution with telemetry
364-
$Output = Measure-CippTask -TaskName $taskName -Metadata $metadata -Script {
365-
Invoke-Command -ScriptBlock { & $FunctionName -Item $Item }
366-
}
363+
Write-Verbose "Activity starting Function: $FunctionName."
364+
Invoke-Command -ScriptBlock { & $FunctionName -Item $Item }
367365
$Status = 'Completed'
368366

369367
Write-Verbose "Activity completed Function: $FunctionName."
@@ -421,8 +419,6 @@ function Receive-CIPPTimerTrigger {
421419

422420
$UtcNow = (Get-Date).ToUniversalTime()
423421
$Functions = Get-CIPPTimerFunctions
424-
Write-Host "CIPP Timer Trigger executed at $UtcNow. Found $($Functions.Count) functions to evaluate. The names are as follows: $($Functions.Command -join ', ')"
425-
Write-Host "CIPPTIMER: $($Functions | ConvertTo-Json -Depth 10 -Compress)"
426422
$Table = Get-CIPPTable -tablename CIPPTimers
427423
$Statuses = Get-CIPPAzDataTableEntity @Table
428424
$FunctionName = $env:WEBSITE_SITE_NAME
@@ -481,9 +477,9 @@ function Receive-CIPPTimerTrigger {
481477
}
482478

483479
# Wrap the timer function execution with telemetry
484-
$Results = Measure-CippTask -TaskName $Function.Command -Metadata $metadata -Script {
485-
Invoke-Command -ScriptBlock { & $Function.Command @Parameters }
486-
}
480+
481+
Invoke-Command -ScriptBlock { & $Function.Command @Parameters }
482+
487483

488484
if ($Results -match '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$') {
489485
$FunctionStatus.OrchestratorId = $Results -join ','

0 commit comments

Comments
 (0)