File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -120,13 +120,15 @@ function Invoke-ListGraphRequest {
120120
121121 try {
122122 $Results = Get-GraphRequestList @GraphRequestParams
123- if ($Results.nextLink ) {
124- Write-Host " NextLink: $ ( $Results.nextLink | Select-Object - Last 1 ) "
123+ if ($Results | Where-Object { $_ .nextLink } ) {
124+ Write-Host " NextLink: $ ( $Results.nextLink | Where-Object { $_ } | Select-Object - Last 1 ) "
125125 if ($Request.Query.TenantFilter -ne ' AllTenants' ) {
126- $Metadata [' nextLink' ] = $Results.nextLink | Select-Object - Last 1
126+ $Metadata [' nextLink' ] = $Results.nextLink | Where-Object { $_ } | Select-Object - Last 1
127+ }
128+ # Remove nextLink trailing object only if it’s the last item
129+ if ($Results [-1 ].PSObject.Properties.Name -contains ' nextLink' ) {
130+ $Results = $Results | Select-Object - First ($Results.Count - 1 )
127131 }
128- # Results is an array of objects, so we need to remove the last object before returning
129- $Results = $Results | Select-Object - First ($Results.Count - 1 )
130132 }
131133 if ($Request.Query.ListProperties ) {
132134 $Columns = ($Results | Select-Object - First 1 ).PSObject.Properties.Name
You can’t perform that action at this time.
0 commit comments