15 49.0138 8.38624 1 0 4000 1 https://vladtalkstech.com 300 1
theme-sticky-logo-alt

Getting More Than 50 External Users With the Get-SPOExternalUser PowerSell cmdlet

4 Comments

One of the reports that a lot of Office 365 admins use, is to see what external users have access to the tenant in SharePoint Online. Luckily, Microsoft offers a PowerShell cmdlet in the SharePoint Online module named Get-SPOExternalUser.

More Than 50 External Users With the Get-SPOExternalUser

While that cmdlet might seem easy and straightforward to use, there is a small catch; it can only return 50 External Users at a time due to a limit on the PageSize Parameter.

More Than 50 External Users With the Get-SPOExternalUser

A lot of scripts that you find on the Internet will give you a command like Get-SPOExternalUser -Position 0 -PageSize 50 … and that will work great , if you have less than 50 users in your tenant! However, if you have more than 50, you will need to do something just a little bit more advanced in order to be able to see all of them. What we will do, is that we will use a For Loop wrapped in a try/catch and try to get 50 users at a time, playing with the -Position parameter until the cmdlet stops returning information. You can view the script below:

try 
{
    for ($i=0;;$i+=50)
	{
        $ExternalUsers += Get-SPOExternalUser -PageSize 50 -Position $i -ea Stop
    }
}
catch 
{

}
$ExternalUsers.Count

 

And here a screenshot example where I am checking the number of users returned, and as you can see it’s over 50, so the script worked!

Leave a comment and don’t forget to like the Vlad Talks Tech Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.

Follow me on Social Media and Share this article with your friends!

Previous Post
Creating a Secret Office 365 Group
Next Post
Create a report of SharePoint Online External Users with PowerShell

4 Comments

Leave a Reply