Aug 25 2021 03:51 AM
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 script and also the link of an article about the explanation of this script -
The problem now is that we are only able to get 1000 devices in the $Devices variable in the above mentioned script and we have around 2000 devices so 1000 more devices are not getting fetched by this script.
Also this script always get the device in the same pattern i.e.. if I run the script today and tomorrow then the devices will show the same pattern that is also the reason the rest 1000 devices are not getting fetched.
Any solution to this issue will be a great help for me.
Regards,
Ashish Arya
Aug 25 2021 06:56 AM
SolutionAug 30 2021 10:11 AM - edited Aug 30 2021 10:13 AM
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:
Aug 25 2021 06:56 AM
Solution