Blog
Hide SharePoint List or Library from Site Contents
Managing access to lists and libraries in SharePoint is crucial for maintaining data security and ensuring that users only see the content they are authorised to view. In this blog, we will share a quick script you can use to hide a list/library from site contents.
Use Cases
There are various scenarios where you might want to hide a list or library. Some examples include
Custom Application Data Storage
When a list is used as a backend data source for a custom solution and should not be accessed directly.
Hiding Configuration Lists
When a list stores settings or metadata that users should not change manually
Reducing Clutter
When a site has multiple technical lists that are not relevant to end users, keeping the Site Contents view clean.
Restricting Access to Sensitive Data
When a list contains confidential or sensitive information and you don’t want users discovering it if permissions are accidentally incorrectly applied.
Avoiding User Confusion
When a list or library holds system-generated data that users don’t need to interact with.

Step-by-Step Guide
Here’s a quick script you can use to hide a list or library from site contents:
$SiteUrl = ”
https://[tenantname].sharepoint.com/ ”
$ListTitle = “[List Title]”
Connect-PnPOnline -Url $SiteUrl -Interactive
Set-PnPList -Identity $ListTitle -Hidden $true
Disconnect-PnPOnline
- Connect to SharePoint Online: Use the Connect-PnPOnline command to connect to your SharePoint site.
- Hide the List/Library: Use the Set-PnPList command to hide the specified list/library.
- Disconnect: Use the Disconnect-PnPOnline command to disconnect from SharePoint Online.
Additional Notes
- Manage Permissions Carefully: You will still need to ensure that the correct permissions are applied on the list as users will still have access to the list/library if they have the URL.
- Hide Search Results: Ensure the hidden lists/libraries are also hidden from search results if they are just storing system data.
Need Assistance?
If you need assistance with any custom SharePoint development, managing access to lists and libraries in SharePoint or have any questions, feel free to get in touch with us. We are here to help!