From b8d13a28b9c8f448d8ea5e5f640b6e841d569c5d Mon Sep 17 00:00:00 2001 From: John Duprey Date: Mon, 27 Jan 2025 10:48:57 -0500 Subject: [PATCH] fix pagination for AllTenants queries --- .../HTTP Functions/CIPP/Core/Invoke-ListGraphRequest.ps1 | 4 +++- .../CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ListGraphRequest.ps1 b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ListGraphRequest.ps1 index 84de0b74395a..45bede27c0b2 100644 --- a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ListGraphRequest.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ListGraphRequest.ps1 @@ -122,7 +122,9 @@ function Invoke-ListGraphRequest { $Results = Get-GraphRequestList @GraphRequestParams if ($Results.nextLink) { Write-Host "NextLink: $($Results.nextLink | Select-Object -Last 1)" - $Metadata['nextLink'] = $Results.nextLink | Select-Object -Last 1 + if ($Request.Query.TenantFilter -ne 'AllTenants') { + $Metadata['nextLink'] = $Results.nextLink | Select-Object -Last 1 + } #Results is an array of objects, so we need to remove the last object before returning $Results = $Results | Select-Object -First ($Results.Count - 1) } diff --git a/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 b/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 index 0d376eda8f9a..98d09f7507c9 100644 --- a/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 +++ b/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 @@ -190,7 +190,7 @@ function Get-GraphRequestList { TenantFilter = $_.defaultDomainName Endpoint = $using:Endpoint Parameters = $using:Parameters - NoPagination = $using:NoPagination.IsPresent + NoPagination = $false ReverseTenantLookupProperty = $using:ReverseTenantLookupProperty ReverseTenantLookup = $using:ReverseTenantLookup.IsPresent NoAuthCheck = $using:NoAuthCheck.IsPresent