My SharePoint Online site gives read only access to all company users; How to stop one user from seeing all sites except a specific document library?

frob 4,261 Reputation points
2021-05-14T23:41:09.833+00:00

Hi there

My SharePoint Online site gives read-only access to all company users; How to stop one user from seeing all sites except a specific document library?

I was able to do that in SharePoint 2013 by from the Central Admin panel at the web application level. Any idea how to get this done in SP Online?

Thanks.

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Accepted answer
  1. CaseyYang-MSFT 10,461 Reputation points
    2021-05-17T08:54:52.39+00:00

    Hi @frob-0826

    Here’re steps:

    1.Remove a user from all site collection with following PowerShell.

    #Config Parameters  
    $AdminSiteURL="https://tenant-admin.sharepoint.com/"  
    $UserAccount = "******@tenant.com"  
    
    #Connect to SharePoint Online Tenant Admin  
    Connect-SPOService -URL $AdminSiteURL -Credential (Get-Credential)  
    
    #Get all Site Collections  
    $SitesCollections = Get-SPOSite -Limit ALL  
    
    #Iterate through each site collection  
    ForEach($Site in $SitesCollections)  
    {  
        Write-host -f Yellow "Checking Site Collection:"$Site.URL  
    
        #Get the user from site collection  
        $User = Get-SPOUser -Limit All –Site $Site.URL | Where {$_.LoginName -eq $UserAccount}  
    
        #Remove the User from site collection  
        If($User)  
        {  
            #Remove the user from the site collection  
            Remove-SPOUser -Site $Site.URL –LoginName $UserAccount  
            Write-host -f Green "`tUser $($UserAccount) has been removed from Site collection!"  
        }  
    }  
    

    Reference:
    https://www.sharepointdiary.com/2018/07/sharepoint-online-powershell-to-remove-user-from-all-sites.html

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.

    2.Set the unique permission for a specific document library.
    Select document library > library settings > Permissions and Management > Permissions for this document library > Stop Inheriting Permissions > Grant Permissions > Select the user and a permission level “Read”.
    97113-1.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.