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.
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.
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 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!
|
The post Getting More Than 50 External Users With the Get-SPOExternalUser PowerSell cmdlet appeared first on Absolute SharePoint Blog by Vlad Catrinescu.
by Vlad Catrinescu via Absolute SharePoint Blog by Vlad Catrinescu
No comments:
Post a Comment