From 873beb87f7eecaa0ecfc7fd0363e6c925fea5f76 Mon Sep 17 00:00:00 2001 From: Chris Brannon Date: Tue, 20 Aug 2024 15:38:27 -0400 Subject: [PATCH 1/2] paging issue --- .../Invoke-ListTeamsVoice.ps1 | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Teams-Sharepoint/Invoke-ListTeamsVoice.ps1 b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Teams-Sharepoint/Invoke-ListTeamsVoice.ps1 index ec33ee67e86e..a5cc63bcf05c 100644 --- a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Teams-Sharepoint/Invoke-ListTeamsVoice.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Teams-Sharepoint/Invoke-ListTeamsVoice.ps1 @@ -22,18 +22,21 @@ Function Invoke-ListTeamsVoice { $tenantid = (Get-Tenants | Where-Object -Property defaultDomainName -EQ $Request.Query.TenantFilter).customerId try { $users = (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users?`$top=999&`$select=id,userPrincipalName,displayname" -tenantid $TenantFilter) - $GraphRequest = (New-TeamsAPIGetRequest -uri "https://api.interfaces.records.teams.microsoft.com/Skype.TelephoneNumberMgmt/Tenants/$($Tenantid)/telephone-numbers?locale=en-US" -tenantid $TenantFilter).TelephoneNumbers | ForEach-Object { - $CompleteRequest = $_ | Select-Object *, 'AssignedTo' - $CompleteRequest.AcquisitionDate = $CompleteRequest.AcquisitionDate -split 'T' | Select-Object -First 1 - - if ($CompleteRequest.TargetId -eq '00000000-0000-0000-0000-000000000000') { - $CompleteRequest.AssignedTo = 'Unassigned' - } else { - $CompleteRequest.AssignedTo = ($users | Where-Object -Property Id -EQ $CompleteRequest.TargetId).userPrincipalName - + $skip = 0 + $GraphRequest = do { + $data = (New-TeamsAPIGetRequest -uri "https://api.interfaces.records.teams.microsoft.com/Skype.TelephoneNumberMgmt/Tenants/$($Tenantid)/telephone-numbers?skip=$($skip)&locale=en-US&top=999" -tenantid $TenantFilter).TelephoneNumbers | ForEach-Object { + $CompleteRequest = $_ | Select-Object *, 'AssignedTo' + $CompleteRequest.AcquisitionDate = $CompleteRequest.AcquisitionDate -split 'T' | Select-Object -First 1 + if ($CompleteRequest.TargetId -eq '00000000-0000-0000-0000-000000000000') { + $CompleteRequest.AssignedTo = 'Unassigned' + } else { + $CompleteRequest.AssignedTo = ($users | Where-Object -Property Id -EQ $CompleteRequest.TargetId).userPrincipalName + } + $CompleteRequest } - $CompleteRequest - } + $skip += 999 + $Data + } while ( $Data.count % 999 -eq 0 ) $StatusCode = [HttpStatusCode]::OK } catch { $ErrorMessage = Get-NormalizedError -Message $_.Exception.Message From 6286c4fde565aff0a8c317454af1e931c72587ce Mon Sep 17 00:00:00 2001 From: Chris Brannon Date: Thu, 22 Aug 2024 19:01:57 -0400 Subject: [PATCH 2/2] += --- .../HTTP Functions/Teams-Sharepoint/Invoke-ListTeamsVoice.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Teams-Sharepoint/Invoke-ListTeamsVoice.ps1 b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Teams-Sharepoint/Invoke-ListTeamsVoice.ps1 index a5cc63bcf05c..2459ff22f13c 100644 --- a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Teams-Sharepoint/Invoke-ListTeamsVoice.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Teams-Sharepoint/Invoke-ListTeamsVoice.ps1 @@ -34,7 +34,7 @@ Function Invoke-ListTeamsVoice { } $CompleteRequest } - $skip += 999 + $skip = $skip + 999 $Data } while ( $Data.count % 999 -eq 0 ) $StatusCode = [HttpStatusCode]::OK