Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error handling, some typos #1110

Merged
merged 6 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function Invoke-CippWebhookProcessing {

$ActionList = ($data.CIPPAction | ConvertFrom-Json -ErrorAction SilentlyContinue).value
$ActionResults = foreach ($action in $ActionList) {
Write-Host "this is our action: $($action | ConvertTo-Json -Depth 15 -Compress))"
Write-Host "this is our action: $($action | ConvertTo-Json -Depth 15 -Compress)"
switch ($action) {
'disableUser' {
Set-CIPPSignInState -TenantFilter $TenantFilter -User $data.UserId -AccountEnabled $false -APIName 'Alert Engine' -ExecutingUser 'Alert Engine'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ Function Invoke-RemoveWebhookAlert {

$APIName = $TriggerMetadata.FunctionName
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$Table = get-cipptable -TableName 'SchedulerConfig'

try {
$WebhookTable = Get-CIPPTable -TableName SchedulerConfig
$WebhookTable = Get-CIPPTable -TableName 'SchedulerConfig'
$WebhookRow = Get-CIPPAzDataTableEntity @WebhookTable -Filter "PartitionKey eq 'WebhookAlert'" | Where-Object -Property Tenant -EQ $Request.query.TenantFilter
Write-Host "The webhook count is $($WebhookRow.count)"
if ($WebhookRow.count -gt 1) {
Expand All @@ -34,7 +33,7 @@ Function Invoke-RemoveWebhookAlert {
}
Remove-AzDataTableEntity @Table -Entity $CompleteObject -ErrorAction SilentlyContinue | Out-Null
} catch {
#
Write-LogMessage -user $Request.headers.'x-ms-client-principal' -API $APIName -message "Failed to remove webhook for AllTenants. $($_.Exception.Message)" -Sev 'Error'
}
} else {
$Tenants = $Request.query.TenantFilter
Expand All @@ -53,10 +52,9 @@ Function Invoke-RemoveWebhookAlert {
$body = [pscustomobject]@{'Results' = "Failed to remove webhook alert: $($_.Exception.Message)" }
}


# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function New-CIPPGraphSubscription {
[switch]$PartnerCenter
)
$CIPPID = (New-Guid).GUID
$WebhookTable = Get-CIPPTable -TableName webhookTable
$WebhookTable = Get-CIPPTable -TableName 'webhookTable'

try {
if ($auditLogAPI) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Remove-CIPPGraphSubscription {
}
}
} else {
$WebhookTable = Get-CIPPTable -TableName webhookTable
$WebhookTable = Get-CIPPTable -TableName 'webhookTable'
if ($type -eq 'AuditLog') {
$WebhookRow = Get-CIPPAzDataTableEntity @WebhookTable | Where-Object { $_.PartitionKey -eq $TenantFilter -and $_.Resource -eq $EventType }
} else {
Expand Down
6 changes: 3 additions & 3 deletions Modules/CIPPCore/Public/Webhooks/Test-CIPPAuditLogRules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ function Test-CIPPAuditLogRules {
Write-Information "Logs to process: $LogCount"
$Results.TotalLogs = $LogCount
if ($LogCount -gt 0) {
$PreProccessedData = $Data | Select-Object *, CIPPAction, CIPPClause, CIPPGeoLocation, CIPPBadRepIP, CIPPHostedIP, CIPPIPDetected, CIPPLocationInfo, CIPPExtendedProperties, CIPPDeviceProperties, CIPPParameters, CIPPModifiedProperties -ErrorAction SilentlyContinue
$PreProcessedData = $Data | Select-Object *, CIPPAction, CIPPClause, CIPPGeoLocation, CIPPBadRepIP, CIPPHostedIP, CIPPIPDetected, CIPPLocationInfo, CIPPExtendedProperties, CIPPDeviceProperties, CIPPParameters, CIPPModifiedProperties -ErrorAction SilentlyContinue
$LocationTable = Get-CIPPTable -TableName 'knownlocationdb'
$ProcessedData = foreach ($Data in $PreProccessedData) {
$ProcessedData = foreach ($Data in $PreProcessedData) {
try {
if ($Data.ExtendedProperties) {
$Data.CIPPExtendedProperties = ($Data.ExtendedProperties | ConvertTo-Json)
Expand Down Expand Up @@ -105,7 +105,7 @@ function Test-CIPPAuditLogRules {
try {
$Location = Get-CIPPGeoIPLocation -IP $Data.clientip
} catch {
Write-Information "Unable to get IP location for $($Data.clientip): $($_.Exception.Messge)"
Write-Information "Unable to get IP location for $($Data.clientip): $($_.Exception.Message)"
}
$Country = if ($Location.CountryCode) { $Location.CountryCode } else { 'Unknown' }
$City = if ($Location.City) { $Location.City } else { 'Unknown' }
Expand Down