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 is six time Microsoft MVP (Since 2015) with over 16 years of extensive experience with major expertise on SharePoint, SharePoint based development, Microsoft 365, Microsoft Teams, .Net Platform and Microsoft BI. He is currently working Sr Microsoft Consultant at Olive + Goose. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past 12 years and worked on different intranet/intranet solutions for private & govt. sector majorly in United states and Gulf region and have experience of working with multiple Fortune 500 companies. He is a trainer, technology evangelist and also speaks in community forums.

Leave a Reply