SharePoint Online Get-SPOUser IsSiteAdm Error 429

Terry N 146 Reputation points
2020-09-10T14:40:37.753+00:00

Is there another way to find Site Administrators in SharePoint Online?

I have tried the following but on some sites I get an error 429.

Get-SPOUser -Site $SiteUrl -Limit All | select DisplayName,LoginName,IsSiteAdmin,IsGroup,@{n="Groups";e={$_.Groups -join ";"}}  | Export-Csv -nti "blabla.csv"

Most of the sites it fails on seem to use the "Everyone except external users" group and this would be in excess of 5000 users which I believe to be the problem.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,680 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,381 questions
0 comments No comments
{count} votes

Accepted answer
  1. Terry N 146 Reputation points
    2020-09-11T12:13:47.687+00:00

    Okay thank you again for your updated answer but that seems lot of trouble just to allow me to get a short list of site admins.

    Been doing a lot of googling and finally managed to resolve the problem by using get-pnpuser instead.

    Get-PnPUser | ? IsSiteAdmin -eq $true
    

    Regards

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Echo Du_MSFT 17,116 Reputation points
    2020-09-11T03:12:14.423+00:00

    @Terry N

    Yes, you are right.

    By design, when a user exceeding usage limits or making too many requests within a single time, SharePoint will return "429 TOO MANY REQUESTS" error. It means SharePoint Online enforce Throttling limits function, in order to preserve service health.

    You could refer to this article Avoid getting throttled or blocked in SharePoint Online to view more information.

    =============================

    @Terry N

    ……………… Updated Answer ………………

    Enforcing limits scope:

    • 10,000 SharePoint groups per site (site collection).
    • Each SharePoint group can have up to 5,000 users.
    • 5,000 role assignments per uniquely permissioned item.

    Because users of the “Everyone except external users” group exceeds 5000 in your SharePoint Online. I suggest you could split "Everyone except external users" group into several groups. You can follow these steps:

    1.You can group internal external by Departments, such as "Sales Dep", "Personnel Dep", "Finance Dep", etc.
    2.Add users in the "Everyone except external users" group to the corresponding group.
    3.Use these groups to replace the "Everyone except external users" group.
    4.You could run the following commands in the SharePoint Online Management Shell as an admin:

    $admin = "username@aabc.onmicrosoft.com"  
    $password = "****"  
    $cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $admin, $(convertto-securestring $Password -asplaintext -force)  
    Connect-SPOService -Url https://aabc-admin.sharepoint.com -Credential $cred  
    $SiteURL= "https://aabc.sharepoint.com/sites/test1"  
    Get-SPOUser -Site $SiteUrl -Limit All | select DisplayName,LoginName,IsSiteAdmin,IsGroup,@{n="Groups";e={$_.Groups -join ";"}} | Export-Csv "D:\report.csv"  
    

    Thanks,
    Echo Du

    =================

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Terry N 146 Reputation points
    2020-09-11T09:49:24.967+00:00

    Thank you for your answer, I have already looked at the Throttling limits page several times to try and work out a way around this but not having much luck.

    So my question was to see if somebody had found a solution for getting Site Admins by any other means using a powershell script.