Skip to content

Commit 67c266a

Browse files
committed
cleanup generic graph request
1 parent 2aa948b commit 67c266a

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

Modules/CIPPCore/Public/Entrypoints/Invoke-ListGraphRequest.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ function Invoke-ListGraphRequest {
116116
$GraphRequestParams.AsApp = $true
117117
}
118118

119-
Write-Host ($GraphRequestParams | ConvertTo-Json)
120-
121119
$Metadata = $GraphRequestParams
122120

123121
try {
124122
$Results = Get-GraphRequestList @GraphRequestParams
125-
123+
if ($Results.nextLink -and $Request.Query.NoPagination) {
124+
$Metadata['nextLink'] = $Results.nextLink | Select-Object -Last 1
125+
#Results is an array of objects, so we need to remove the last object before returning
126+
$Results = $Results | Select-Object -First ($Results.Count - 1)
127+
}
126128
if ($Request.Query.ListProperties) {
127129
$Columns = ($Results | Select-Object -First 1).PSObject.Properties.Name
128130
$Results = $Columns | Where-Object { @('Tenant', 'CippStatus') -notcontains $_ }

Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,6 @@ function Get-GraphRequestList {
295295
if ($nextLink) { $GraphRequest.uri = $nextLink }
296296

297297
$GraphRequestResults = New-GraphGetRequest @GraphRequest -Caller 'Get-GraphRequestList' -ErrorAction Stop
298-
if ($GraphRequestResults.nextLink) {
299-
#$Metadata['nextLink'] = $GraphRequestResults.nextLink | Select-Object -Last 1
300-
#GraphRequestResults is an array of objects, so we need to remove the last object before returning
301-
$GraphRequestResults = $GraphRequestResults | Select-Object -First ($GraphRequestResults.Count - 1)
302-
}
303298
$GraphRequestResults = $GraphRequestResults | Select-Object *, @{n = 'Tenant'; e = { $TenantFilter } }, @{n = 'CippStatus'; e = { 'Good' } }
304299

305300
if ($ReverseTenantLookup -and $GraphRequestResults) {

0 commit comments

Comments
 (0)