File tree Expand file tree Collapse file tree
Modules/CIPPCore/Public/AuditLogs Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments