SharePoint Online: How to Hide a List or Library using PowerShell?

Requirement: Hide a list or library from SharePoint Online site.

hide list or document library in sharepoint online using powershell

SharePoint Online: Hide a Document Library using PowerShell

For a custom application, we wanted to hide the config list in SharePoint Online to prevent edits or deletions. How to hide a list in SharePoint Online? There are many ways to hide a SharePoint Online list. Here is the PowerShell CSOM script to create hidden lists in SharePoint Online:

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Config Parameters
$SiteURL= ""

#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)

Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred
    #Get the web and Library

    #Hide the list
    $List.Hidden = $True
    Write-host -f Green "List hidden Successfully!"
Catch {
    write-host -f Red "Error hiding List: " $_.Exception.Message

Although the list is hidden from the site contents page, Everything will work as usual in the list, and you can still access it via the list URL.

SharePoint Online: Hide List using PnP PowerShell

Once you execute this script, the given list is immediately hidden from the site contents page. However, The list can be accessed via URL, and all the operations on that list will work as usual.

#Config Variables
$SiteURL = ""
$ListName ="AppConfig"

#Connect PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#SharePoint Online Hide a List
Set-PnPList -Identity $ListName -Hidden $True

To make a list visible again, just set the value of the “hidden” flag to “False”. We can’t directly create a hidden list in SharePoint Online, but we can set its property hidden once added.

SharePoint Online Hidden List using SharePoint Designer

We can also use SharePoint Designer to mark a list hidden from the browser. Read more here: How to hide a list in SharePoint?

how to hide list in sharepoint online

How to view hidden lists in SharePoint Online?

SharePoint Online and its applications use certain hidden lists to store its configuration data. E.g. “Access Requests”, “Composed Looks”, “User Information List”, etc. To get all hidden lists in SharePoint Online, use this PowerShell script:

#Connect to PnP Online
Connect-PnPOnline -Url "" -Interactive

#Get Hidden Lists and Libraries
Get-PnPList | Where { $_.Hidden -eq $true}

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

2 thoughts on “SharePoint Online: How to Hide a List or Library using PowerShell?

  • I wonder, If there is a way to get all hidden lists in a SharePoint Online site..


Leave a Reply