Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-All parameter should automatically set -PageSize=999 #2769

Open
Licantrop0 opened this issue May 31, 2024 · 6 comments
Open

-All parameter should automatically set -PageSize=999 #2769

Licantrop0 opened this issue May 31, 2024 · 6 comments
Labels
type:feature New experience request

Comments

@Licantrop0
Copy link
Member

Licantrop0 commented May 31, 2024

When listing all items, it's much more efficient to query the maximum Microsoft Graph PageSize, 999 items ($top parameter), instead of the default 20.
The -All queries could be up to 50 times faster, as it reduces roundtrips using @odata.nextLink.

If a query has -All parameter, it should automatically set -PageSize 999 if not otherwise specified in the query.

@Licantrop0 Licantrop0 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:feature New experience request labels May 31, 2024
@12Knocksinna
Copy link

Good idea!

@petrhollayms petrhollayms removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Jun 3, 2024
@alexandair
Copy link
Contributor

@Licantrop0 Why have you mentioned the $top parameter when the -PageSize is responsible for the page size?

@Licantrop0
Copy link
Member Author

Licantrop0 commented Jul 14, 2024

@Licantrop0 Why have you mentioned the $top parameter when the -PageSize is responsible for the page size?

because PageSize sets the Top parameter, see: https://github.com/microsoftgraph/msgraph-sdk-powershell/blob/bf523777647903ef7098e0a5dd5d3e98703c08eb/tools/Custom/ListCmdlet.cs#L119C12-L123C14

@Licantrop0
Copy link
Member Author

Licantrop0 commented Jul 14, 2024

@petrhollayms, I discovered that this was asked already a while ago and it breaks some scenarios, see: #1230 and: #1248, maybe we should reconsider this.

@alexandair
Copy link
Contributor

@Licantrop0
You are right. -PageSize sets the $top query parameter.
What confused me is that $top behaves differently depending on the other used parameters.

If -Top is used without the -Pagesize, -Top sets the $top.
If -Top is used with the -Pagesize, -Pagesize sets $top, but -Top controls how many items will be returned.

-PageSize cannot be greater than 999. However, -Top can be greater than 999, and command like Get-MgUser -Top 1000 -PageSize 999 will return 1000 users making 2 requests (999+1) to the MSGraph endpoint. (I assume this. I haven't tested it.)

It's possible to specify -Top and -All at the same time, but I don't understand why would you do that. -Top and -All should be in different parameter sets, right?

@Licantrop0
Copy link
Member Author

@peombwa wrote that code and he would be the best explaining the behavior.
FYI @SteveMutungi254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New experience request
Projects
None yet
Development

No branches or pull requests

4 participants