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, 2021HI maybe this could help you solve it?
"@odata.count": 1000,
"@odata.nextLink":
https://docs.microsoft.com/en-us/graph/paging
HI maybe this could help you solve it?
"@odata.count": 1000,
"@odata.nextLink":
https://docs.microsoft.com/en-us/graph/paging
"@odata.count": 1000,
"@odata.nextLink":
https://docs.microsoft.com/en-us/graph/paging
Ashish_Arya
Aug 30, 2021Brass Contributor
Thanks a lot Rudy_Ooms_MVP for your reply.
This has fixed my issue. Now I am able to get the other devices as well.
Below if the code which I added to script -
$DevicesResponse = (Invoke-RestMethod -Uri $uri -Headers $authToken -Method Get)
$Devices = $DevicesResponse.value
$DevicesNextLink = $DevicesResponse."@odata.nextLink"
while ($DevicesNextLink -ne $null){
$DevicesResponse = (Invoke-RestMethod -Uri $DevicesNextLink -Headers $authToken -Method Get)
$DevicesNextLink = $DevicesResponse."@odata.nextLink"
$Devices += $DevicesResponse.value
}
return $Devices
Below is the script for reference: