Skip to content

Get-MgUser fails for a tenant with a large number of users, but Get-MgUser -All -PageSize 400 succeed. #1192

Closed

Description

I create a test tenant with 40,000 users.

Using PowerShell 5.1, "Get-MgUser -All" causes the StackOverflowExeption.
Given the related issue (#949), This result is to be expected.

Howerver, "Get-MgUser -All -PageSize 400" succeed.

Why does it work with large PageSize ?

The result of verification is as follows:

PS C:\Users\kutsu> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.22000.593
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22000.593
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PS C:\Users\kutsu> (Get-MgUser -All -PageSize 400).count
40002
PS C:\Users\kutsu> (Get-MgUser -All).count

Process is terminated due to StackOverflowException.

Activity

  1. changed the title [-]Get-MgUser fails fo a tenant with a large number of users, but Get-MgUser -All -PageSize 400 succeed.[/-] [+]Get-MgUser fails for a tenant with a large number of users, but Get-MgUser -All -PageSize 400 succeed.[/+] on Apr 5, 2022
  2. peombwa commented on Apr 14, 2022

    @peombwa
    Member

    Thanks for bringing this to our attention. We are investigating the root cause of this error as it is isolated to PowerShell 5.1.

  3. peombwa commented on Apr 21, 2022

    @peombwa
    Member

    We've traced the bug to a recursion depth issue in PS 5.1 when there are more than ~250 pages to be fetched. Thanks, Kutsuzawa Ryo (@mr-oliva), and the team, for the memory dumps.

    The workaround is to increase the -PageSize to something like Get-MgUser -All -PageSize 400 to reduce the number of pages or upgrade to PowerShell 7.x.

    We will provide a fix in the upcoming release.

  4. peombwa commented on Apr 21, 2022

    @peombwa
    Member

    A fix will be provided by Azure/autorest.powershell#932.

  5. mr-oliva commented on Apr 25, 2022

    @mr-oliva
    Author

    I'm sorry for my late response and understand that there is a problem.
    Thank you for check this issue.
    I'll try again after update autorest.powershell.

  6. peombwa commented on May 6, 2022

    @peombwa
    Member

    Kutsuzawa Ryo (@mr-oliva), we've just release version 1.9.6 with the fix - https://github.com/microsoftgraph/msgraph-sdk-powershell/releases/tag/1.9.6. Please give it a try and let us know if the issue persists. Thanks!

  7. watahani commented on May 10, 2022

    @watahani

    Peter Ombwa (@peombwa) Thank you for your assistance. It works fine for me!

  8. mr-oliva commented on May 11, 2022

    @mr-oliva
    Author

    Peter Ombwa (@peombwa) I confirmed that the problem has been resolved. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions