Recently I was in a need to get a list of all the users from a list of O365 Site Collections and I thought of following approaches to do this:
Approach 1:
- Get a list of site collections in a CSV
- Loop through them one by one
- From each site collection get a list of groups
and download users in it - There will be other users added directly to the
site collection. In that case get the user from each web directly.
But there are many gotchas with
this approach:
- What if user has broken permissions to a page or
library and added user(s) directly to that? - Same goes with a subsite
Approach 2:
- We know that every site collection has a User
Information List, which is hidden - You can access it appending ‘/_catalogs/users/simple.aspx’
to your site collection - Every user added to the site collection, no matter
where, it will go and sit in the User Information List at the Site Collection
level - Simplistically thinking the User Information List
is just another SharePoint list. You can access it using the Web object as Web.SiteUserInfoList
Therefore, approach 2 seemed more appropriate and can be
achieved in quick time. You can access the code here.

If you liked the article, share it with your friends and colleagues. You can also send a “Thank you” note by buying me a coffee. Buy Me a Coffee