Skip to content

Commit

Permalink
added write hosts for troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Aug 7, 2023
1 parent c8cf8a4 commit 0467f85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Modules/CIPPCore/Public/Invoke-CIPPWebhookProcessing.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Invoke-CippWebhookProcessing {
if ($data.operation -eq "UserloggedIn" -and $data.UserType -eq 2) { $data.operation = "AdminLoggedIn" }
if ($data.operation -eq "UserLoggedIn" -and $Country -notin $AllowedLocations) { $data.operation = "UserLoggedInFromUnknownLocation" }
if ($data.operation -eq "UserLoggedIn" -and $Country -notin $PreviousLocations) { $data.operation = "UserLoggedInFromUnknownLocation" }

Write-Host "Selecting the Operation: $($data.operation)"
switch ($data.Operation) {
"New-InboxRule" {
$Title = "$($TenantFilter) - New Rule Detected for $($data.UserId)"
Expand Down Expand Up @@ -140,7 +140,7 @@ function Invoke-CippWebhookProcessing {
}
$HTML = "$HTML" -f $Title, $IntroText, $ButtonUrl, $ButtonText, $AfterButtonText

#Add IP and potential location to knownlocation db for this specific user
Write-Host "Add IP and potential location to knownlocation db for this specific user"
if ($data.ClientIP) {
$LocationInfo = @{
RowKey = [string]$data.ClientIP.Split(':')[0]
Expand All @@ -159,7 +159,10 @@ function Invoke-CippWebhookProcessing {
PotentialCity = $City
} | ConvertTo-Json -Depth 15 -Compress

Write-Host "Sending alert to email"
Send-CIPPAlert -Type 'email' -Title $title -HTMLContent $HTML
Write-Host "Sending alert to webhook"
Send-CIPPAlert -Type 'webhook' -Title $title -JSONContent $JsonContent
Write-Host "Sending alert to PSA"
Send-CIPPAlert -Type 'psa' -Title $title -HTMLContent $HTML
}
8 changes: 7 additions & 1 deletion Modules/CIPPCore/Public/Send-CIPPAlert.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ function Send-CIPPAlert {
$APIName = "Send Alert",
$ExecutingUser
)

Write-Host "Shipping Alert"
$Table = Get-CIPPTable -TableName SchedulerConfig
$Filter = "RowKey eq 'CippNotifications' and PartitionKey eq 'CippNotifications'"
$Config = [pscustomobject](Get-AzDataTableEntity @Table -Filter $Filter)
if ($Type -eq 'email') {
Write-Host "Trying to send email"
try {
if ($Config.email -like '*@*') {
$Recipients = $Config.email.split(",").trim() | ForEach-Object { if ($_ -like '*@*') { [pscustomobject]@{EmailAddress = @{Address = $_ } } } }
Expand All @@ -41,7 +42,10 @@ function Send-CIPPAlert {
}

}

if ($Type -eq 'webhook') {
Write-Host "Trying to send webhook"

try {
if ($Config.webhook -ne '') {
switch -wildcard ($config.webhook) {
Expand All @@ -68,6 +72,8 @@ function Send-CIPPAlert {
Write-LogMessage -API 'Alerts' -message "Could not send alerts to : $($_.Exception.message)" -sev info
}
}
Write-Host "Trying to send to PSA"

if ($Type -eq 'psa') {
if ($config.sendtoIntegration) {
try {
Expand Down

0 comments on commit 0467f85

Please sign in to comment.