SharePoint lists and libraries are visible to all users and there are various ways to hide them. Admin can break inheritance for the list/libraries and set permissions for a specific group of users, this will hide the list from all users except that specific group and list content will only be available if user have the permissions. But sometime we can have few list or libraries where we added some configuration information and do not want user to directly access that but the list items or documents can be shown to them through different web parts, in this scenario the break inheritance will not work and we might have to use either PowerShell or SharePoint designer (or stsadm for older versions). In this blog post I am going to share the PowerShell script to show/hide the list and libraries in SharePoint online and SharePoint on-premise and also how we can achieve this using SharePoint Designer. You can download the PowerShell script for SharePoint Online and on-premise from TechNet.

SharePoint Hide show list and libraries

Hide list and libraries in SharePoint Online

Use the below PowerShell script to show or hide the list and library from the users for SharePoint Online (Office 365). I have written a simple function.

$userName="admin@mstechtalk.com"
$password =Read-Host -Prompt "Enter Password" -AsSecureString 

#Setup Credentials to connect
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName,$password)

function ShowHideList($siteUrl, $listName, $showHideValue)
{
    #Set up the context
    $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
    $context.Credentials = $credentials

    #Get the List
    $list = $context.Web.Lists.GetByTitle($listName)
    $list.Hidden = $showHideValue
    $list.Update()
    $context.ExecuteQuery()
    if ($showHideValue -eq $true)
    {
        Write-Host "$listName hidden successfully!"
    }else{
        Write-Host "$listName enabled/shown successfully!"
    }
}

You have to call the function ShowHideList which require three parameters.

#site URL, List/Library name, $true/$false 
ShowHideList "https://mstalk.sharepoint.com" "Opportunities" $false

You can easily show/hide a SharePoint List or library using above function in SharePoint Online. Download the above PowerShell script from GitHub.

Hide list and libraries in SharePoint On-premise

Use the below PowerShell script to show or hide the list and library from the users for SharePoint On-Premise (SharePoint 2010, SharePoint 2013, SharePoint 2016, SharePoint Foundation). Just like the script written in above section, I have written a PowerShell script having the same function name but for on-premise environment.

function ShowHideList($siteUrl, $listName, $showHideValue)
{
    $web = Get-SPWeb $siteUrl
    #Get the List
    $list = $web.Lists[$listName]
 
    #Set the Hidden Property to show or hide
    $list.Hidden = $showHideValue
    $list.Update()

    if ($showHideValue -eq $true)
        {
            Write-Host "$listName hidden successfully!"
        }else{
            Write-Host "$listName enabled/shown successfully!"
        }
    $web.Dispose()
}

You have to call the function ShowHideList which require three parameters.

#site URL, List/Library name, $true/$false 
ShowHideList "https://sharepoint2016" "Internal Documents" $true 

Download the above PowerShell script from GitHub.

Hide list or Library using SharePoint Designer

SharePoint Designer is a very useful tool when you need to do some customizations, if you do not have development expertise to execute any PowerShell Script then you can easily do it using SharePoint Designer.

Open the site in SharePoint designer and click on Lists and Libraries from left panel. This will show all the list and libraries in current particular site.

SharePoint Hide show list and libraries - SPD

Click on the list or library which you want to show or hide from the browser or view site content. In the settings section, click on the “Hide from Browser” under General. Save the changes and refresh site in browser, the list/library is now hidden from all users.

SharePoint Hide show list and libraries - SPD

Note: The above methods will only hide the list/library for browser view but user still can access it using URLs.

Adnan, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose. Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies. Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.

Leave a Reply