Skip to content

Commit 3c2022d

Browse files
committed
filter queries
1 parent 792895f commit 3c2022d

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

Modules/CIPPCore/Public/AuditLogs/Get-CippAuditLogSearches.ps1

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,26 @@ function Get-CippAuditLogSearches {
1313
[Parameter()]
1414
[switch]$ReadyToProcess
1515
)
16-
$Queries = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/security/auditLog/queries' -AsApp $true -tenantid $TenantFilter
16+
1717
if ($ReadyToProcess.IsPresent) {
1818
$AuditLogSearchesTable = Get-CippTable -TableName 'AuditLogSearches'
1919
$PendingQueries = Get-CIPPAzDataTableEntity @AuditLogSearchesTable -Filter "Tenant eq '$TenantFilter' and CippStatus eq 'Pending'"
20+
21+
$BulkRequests = foreach ($PendingQuery in $PendingQueries) {
22+
@{
23+
id = $PendingQuery.RowKey
24+
url = 'security/auditLog/queries/' + $PendingQuery.RowKey
25+
method = 'GET'
26+
}
27+
}
28+
if ($BulkRequests.Count -eq 0) {
29+
return @()
30+
}
31+
$Queries = New-GraphBulkRequest -Requests @($BulkRequests) -AsApp $true -TenantId $TenantFilter | Select-Object -ExpandProperty body
32+
2033
$Queries = $Queries | Where-Object { $PendingQueries.RowKey -contains $_.id -and $_.status -eq 'succeeded' }
34+
} else {
35+
$Queries = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/security/auditLog/queries' -AsApp $true -tenantid $TenantFilter
2136
}
2237
return $Queries
2338
}

0 commit comments

Comments
 (0)