Forum Discussion
Ashish_Arya
Aug 25, 2021Brass Contributor
With Graph API we are only getting 1000 devices
HI Team, We are using the below PowerShell script to change the Primary user of a device by checking the last logged in userid. Below is the github repo link which holds this PowerShell scrip...
- Aug 25, 2021
Ashish_Arya This script indeed does not add "paging" to retrieve additional devices if they exist. This is evident because it uses the "Get-Win10IntuneManagedDevice" function inside the script, which only does one call to the Graph API endpoint. You could potentially modify this function to do paging, on the other hand, there's a Graph PowerShell module nowadays which could potentially be used to replace parts of this script's custom code with simpler out of the box cmdlets.
The code responsible for only returning a subset is this:
else { $Resource = "deviceManagement/managedDevices?`$filter=(((deviceType%20eq%20%27desktop%27)%20or%20(deviceType%20eq%20%27windowsRT%27)%20or%20(deviceType%20eq%20%27winEmbedded%27)%20or%20(deviceType%20eq%20%27surfaceHub%27)))" $uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)" (Invoke-RestMethod -Uri $uri -Headers $authToken -Method Get).value }
For more information on how paging works in Graph API, you can have a look at this URL.
mjrogers
Aug 25, 2023Copper Contributor
Thanks so much, this is working perfectly.
Ashish_Arya
Aug 26, 2023Brass Contributor
mjrogers You're welcome 😊.