How To Hide SharePoint List Using PnP PowerShell

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,
  1. #Site URL where SharePoint List Exist replace the URL with your actaull site URL  
  2. $SiteURL = "https://sptest.abc.com"  
  3. #List name that you want to hide  
  4. $ListName = "TestList"  
  5. #Connect to PNP Online  
  6. Connect-PnPOnline -Url $SiteURL -UseWebLogin  
  7. #Hide the list using PnP PowerShell  
  8. 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.