SharePoint Online: Check if a specific user has access to all the Site Collection

The easiest way to check on how to check if a user has permission on the site

1.Navigate to The site collection Example :- https://contoso.sharepoint.com/sites/xyz

2.Click on Gear Icon Toward top right corner > Select option “Site information” > Select option  “View All settings”

3.Click on option “Site Permission”

This image has an empty alt attribute; its file name is image-2-1024x349.png

4. Click on option “Check Permission” and enter the email address of the user >and then select option “Check Now” > it will show the permissions for the user for a specific site assigned.

But if you have a requirement to check a user has access to how many site collection, on this post will provide you a CSOM script which provide on which site collections a specific user has access.

Script

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

 $AdminSiteURL=”https://contoso-admin.sharepoint.com”

#Connect to SharePoint Online Admin

Write-host “Connecting to Admin Center…” -f Yellow

Connect-SPOService -url $AdminSiteURL

Write-host “Getting All Site collections…” -f Yellow

#Get each site collection and users

$Sites = Get-SPOSite -Limit ALL

Foreach($Site in $Sites)

{

    Write-host “Getting Users from Site collection:”$Site.Url -f Yellow

    Get-SPOUser -Limit ALL -Site $Site.Url | Select DisplayName, LoginName, UserType | Where-Object {$_.LoginName -eq “[email protected]”}

}

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

Note

  • on line number 1 – Replace your domain name for AdminSiteURL
  • on line number 14 – Replace User email address

This script connects to your SharePoint Online site collection with PowerShell, gets all the sites collection and then check  if a specific user mentioned in the script has access to the site collections.

 Output

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