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

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

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:

 

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 Absolute SharePoint Blog 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!

5/5 (3)

Please rate this

 
Comments

HI Vlad,
I am very new to PowerShell and I am trying to get this to work, but I keep getting an error “The term ‘Get-SPOsite’ is not recognized as the mname of a cmdlet.

I also dont see where you are connecting to the site.

Thanks,
Joe

Hello Joe,

The connect part was not covered in this blog post. Check out this TechNet page to see the how-to : https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-online/connect-sharepoint-online?view=sharepoint-ps

Also, if you want to go deeper into PowerShell for O365, get a free Pluralsight subscription here: https://absolute-sharepoint.com/2015/12/free-pluralsight-6-month-subscription.html and then you can take the courses specified here: https://absolute-sharepoint.com/2018/03/resources-to-learn-powershell-for-office-365.html

Thanks,

Leave a Reply