Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP-API into…
Browse files Browse the repository at this point in the history
… dev
  • Loading branch information
KelvinTegelaar committed Oct 13, 2023
2 parents a1c60a8 + 0bdd7a6 commit 7c08e03
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Scheduler_CIPPNotifications/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ try {
}
"@
New-GraphPostRequest -uri 'https://graph.microsoft.com/v1.0/me/sendMail' -tenantid $env:TenantID -type POST -body ($JSONBody)
Write-LogMessage -API 'Alerts' -message "Sent alerts to: $($Config.email)" -tenant $Tenant -sev info
}
}
}
Expand Down Expand Up @@ -78,12 +79,13 @@ try {
}
"@
New-GraphPostRequest -uri 'https://graph.microsoft.com/v1.0/me/sendMail' -tenantid $env:TenantID -type POST -body ($JSONBody)
Write-LogMessage -API 'Alerts' -message "Sent alerts to: $($Config.email)" -tenant $Tenant -sev info
}
}
}
catch {
Write-Host "Could not send alerts to email: $($_.Exception.message)"
Write-LogMessage -API 'Alerts' -message "Could not send alerts to : $($_.Exception.message)" -sev info
Write-LogMessage -API 'Alerts' -message "Could not send alerts to: $($_.Exception.message)" -tenant $Tenant -sev error
}


Expand Down Expand Up @@ -119,7 +121,7 @@ try {
Invoke-RestMethod -Uri $config.webhook -Method POST -ContentType 'Application/json' -Body $JSONBody
}
}

Write-LogMessage -API 'Alerts' -tenant $Tenant -message "Sent Webhook to $($config.webhook) " -tenant $Tenant -sev info
}

$UpdateLogs = $CurrentLog | ForEach-Object {
Expand All @@ -132,7 +134,7 @@ try {
}
catch {
Write-Host "Could not send alerts to webhook: $($_.Exception.message)"
Write-LogMessage -API 'Alerts' -message "Could not send alerts to : $($_.Exception.message)" -sev info
Write-LogMessage -API 'Alerts' -message "Could not send alerts to : $($_.Exception.message)" -tenant $Tenant -sev error
}

if ($config.sendtoIntegration) {
Expand All @@ -153,10 +155,11 @@ if ($config.sendtoIntegration) {
Add-AzDataTableEntity @Table -Entity $UpdateLogs -Force
}
}
Write-LogMessage -API 'Alerts' -tenant $Tenant -message "alerts to PSA" -sev info
}
catch {
Write-Host "Could not send alerts to ticketing system: $($_.Exception.message)"
Write-LogMessage -API 'Alerts' -tenant $Tenant -message "Could not send alerts to ticketing system: $($_.Exception.message)" -sev info
Write-LogMessage -API 'Alerts' -tenant $Tenant -message "Could not send alerts to ticketing system: $($_.Exception.message)" -sev Error
}
}

Expand Down

0 comments on commit 7c08e03

Please sign in to comment.