msgraph-sdk-powershell
msgraph-sdk-powershell copied to clipboard
Implementation of the paging is incorrect
Describe the bug
When used together, -Top and -PageSize return incorrect number of items when $topValue cannot be divided by $PageSizeValue without a remainder.
# it returns 4 items, although 3 items are requested; `4 items = 2 pages X 2 items` instead of `3 items = (1 page X 2 items) + 1 item`
PS> get-mguser -top 3 -PageSize 2
DisplayName Id
----------- --
Abby Brown2 7d1a89a8-0029-4e19-a256-cac05295a1
Adele Mance ac4de573-e369-4dcb-bbd2-170c4a0b66
Adele Vance 7ff931dc-2ecf-4e51-8e0b-04e7aaf347
Aleksandar Nikolic cc6166e6-acf1-419b-b06d-f44abb945b
# returns 9 items although 7 items are requested; `9 items = 3 pages X 3 items` instead of `7 items = (2 pages X 3 items) + 1 item`
PS> get-mguser -top 7 -PageSize 3
DisplayName Id
----------- --
Abby Brown2 7d1a89a8-0029-4e19-a256-cac05295a1
Adele Mance ac4de573-e369-4dcb-bbd2-170c4a0b66
Adele Vance 7ff931dc-2ecf-4e51-8e0b-04e7aaf347
Aleksandar Nikolic cc6166e6-acf1-419b-b06d-f44abb945b
Aleksandar Nikolic 177fdb14-fa62-4d84-a8fb-bd635c3981
Alex Wilber 3626d3fe-5bf7-4f85-9e40-9fd5a22663
Bob Brown 78b8ffac-8bea-44a0-961a-62870b2c87
Diego Siciliani 4b1fda38-cc2e-42e9-afd1-18f1d18874
Grady Archie ae0342e9-5cf9-416e-9fb7-154ec6eb27
Expected behavior
It's expected to get the number of items specified with the -Top parameter.
How to reproduce
# it returns 4 items, although 3 items are requested
PS> get-mguser -top 3 -PageSize 2
# returns 9 items although 7 items are requested
PS> get-mguser -top 7 -PageSize 3
SDK Version
2.20.0
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_