Skip to content

Commit e9017f6

Browse files
committed
Fixes manual pagination
1 parent f57e286 commit e9017f6

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Modules/CIPPCore/Public/GraphHelper/New-GraphGetRequest.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function New-GraphGetRequest {
107107
} else {
108108
if ($Data.PSObject.Properties.Name -contains 'value') { $data.value } else { $Data }
109109
if ($noPagination -eq $true) {
110-
if ($Caller -eq 'Get-GraphRequestList') {
110+
if ($Caller -eq 'Get-GraphRequestList' -and $data.'@odata.nextLink') {
111111
@{ 'nextLink' = $data.'@odata.nextLink' }
112112
}
113113
$nextURL = $null

Modules/CIPPHTTP/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ListGraphRequest.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,13 @@ function Invoke-ListGraphRequest {
159159
if ($NextLink -and $Request.Query.TenantFilter -ne 'AllTenants') {
160160
Write-Host "NextLink: $NextLink"
161161
$Metadata['nextLink'] = $NextLink
162+
} else {
163+
$Metadata.Remove('nextLink')
162164
}
163-
# Remove nextLink trailing object only if its the last item
165+
# Remove nextLink trailing object only if it's the last item
164166
$Results = $Results | Where-Object { $_.PSObject.Properties.Name -notcontains 'nextLink' }
167+
} else {
168+
$Metadata.Remove('nextLink')
165169
}
166170
if ($Request.Query.ListProperties) {
167171
$Columns = ($Results | Select-Object -First 1).PSObject.Properties.Name

0 commit comments

Comments
 (0)