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 Document Library using PowerShell
For a custom application, we wanted to hide the config list in SharePoint Online, to prevent edit 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 list URL.

SharePoint Online: Hide List using PnP PowerShell
Once you execute this script, the given list goes hidden from the site contents page immediately. 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 the 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 uses 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 "" -UseWebLogin

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


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

    1. Sure, You can use: Get-PnPList | Where { $_.Hidden -EQ $True}


Please Login and comment to get your questions answered!

Powered by Blogger.