In this tutorial, I show you how to hide a SharePoint list using PnP PowerShell. Before you run the script you must install the PnP PowerShell package for your On-Premises or online environment.
Prerequisite for PnP PowerShell
Run the below command to install the PnP package. For this sample, I am installing the PnP package for SharePoint 2016 On-premises.
Install-Module SharePointPnPPowerShell2016
When you ran the above command it asks for confirmation kindly confirm to "Yes" and it installed the SharePoint 2016 PnP PowerShell module and now you can access the SharePoint objects using PnP Cmdlets.
Hide the SharePoint List using PnP PowerShell
Set all below variable as your environment and run the command to hide the SharePoint list,
- #Site URL where SharePoint List Exist replace the URL with your actaull site URL
- $SiteURL = "https://sptest.abc.com"
- #List name that you want to hide
- $ListName = "TestList"
- #Connect to PNP Online
- Connect-PnPOnline -Url $SiteURL -UseWebLogin
- #Hide the list using PnP PowerShell
- Set-PnPList -Identity $ListName -Hidden $true Disconnect-PnPOnline
So using the above PnP PowerShell script you Hide the "TestList" from the site provided.
Advantage of PnP PowerShell over Windows PowerShell
PnP(Patterns & Practices) use CSOM internally so you don't need server access to run the script means you can access your production environment SharePoint objects from your host machine.
Conclusion
This is how you can hide the SharePoint list using PnP PowerShell. Just make sure to install the PnP PowerShell package prerequisite before running the script.