From 0546b72a4ba2b6f2a27f8c78f9f0cb0db7ab602a Mon Sep 17 00:00:00 2001 From: John Duprey Date: Thu, 3 Oct 2024 18:11:04 -0400 Subject: [PATCH 1/2] AsApp support --- .../Graph Requests/Push-ListGraphRequestQueue.ps1 | 1 + .../Public/GraphRequests/Get-GraphRequestList.ps1 | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Graph Requests/Push-ListGraphRequestQueue.ps1 b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Graph Requests/Push-ListGraphRequestQueue.ps1 index b3f88c0b9e73..c7b2de89ec5a 100644 --- a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Graph Requests/Push-ListGraphRequestQueue.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Graph Requests/Push-ListGraphRequestQueue.ps1 @@ -34,6 +34,7 @@ function Push-ListGraphRequestQueue { NoPagination = $Item.NoPagination ReverseTenantLookupProperty = $Item.ReverseTenantLookupProperty ReverseTenantLookup = $Item.ReverseTenantLookup + AsApp = $Item.AsApp ?? $false SkipCache = $true } diff --git a/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 b/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 index 43d7617833c1..ba85c3884bbf 100644 --- a/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 +++ b/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 @@ -64,7 +64,8 @@ function Get-GraphRequestList { [switch]$CountOnly, [switch]$NoAuthCheck, [switch]$ReverseTenantLookup, - [string]$ReverseTenantLookupProperty = 'tenantId' + [string]$ReverseTenantLookupProperty = 'tenantId', + [boolean]$AsApp = $false ) $SingleTenantThreshold = 8000 @@ -110,6 +111,9 @@ function Get-GraphRequestList { if ($NoAuthCheck.IsPresent) { $GraphRequest.noauthcheck = $NoAuthCheck.IsPresent } + if ($AsApp) { + $GraphRequest.asApp = $AsApp + } if ($Parameters.'$count' -and !$SkipCache.IsPresent -and !$NoPagination.IsPresent) { $Count = New-GraphGetRequest @GraphRequest -CountOnly -ErrorAction Stop if ($CountOnly.IsPresent) { return $Count } @@ -174,6 +178,8 @@ function Get-GraphRequestList { NoPagination = $using:NoPagination.IsPresent ReverseTenantLookupProperty = $using:ReverseTenantLookupProperty ReverseTenantLookup = $using:ReverseTenantLookup.IsPresent + NoAuthCheck = $using:NoAuthCheck.IsPresent + AsApp = $using:AsApp SkipCache = $true } @@ -220,6 +226,7 @@ function Get-GraphRequestList { PartitionKey = $PartitionKey NoPagination = $NoPagination.IsPresent NoAuthCheck = $NoAuthCheck.IsPresent + AsApp = $AsApp ReverseTenantLookupProperty = $ReverseTenantLookupProperty ReverseTenantLookup = $ReverseTenantLookup.IsPresent } From 595892526c9690478c266b685abf40a26570ef4f Mon Sep 17 00:00:00 2001 From: John Duprey Date: Thu, 3 Oct 2024 18:31:33 -0400 Subject: [PATCH 2/2] Update Get-GraphRequestList.ps1 --- Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 b/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 index ba85c3884bbf..769796f02504 100644 --- a/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 +++ b/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 @@ -296,7 +296,7 @@ function Get-GraphRequestList { $GraphRequestResults = New-GraphGetRequest @GraphRequest -Caller 'Get-GraphRequestList' -ErrorAction Stop if ($GraphRequestResults.nextLink) { - $Metadata['nextLink'] = $GraphRequestResults.nextLink | Select-Object -Last 1 + #$Metadata['nextLink'] = $GraphRequestResults.nextLink | Select-Object -Last 1 #GraphRequestResults is an array of objects, so we need to remove the last object before returning $GraphRequestResults = $GraphRequestResults | Select-Object -First ($GraphRequestResults.Count - 1) }