How to Hide a List View in SharePoint using PowerShell?

Requirement: Hide a List View in SharePoint

sharepoint hide a list view

How to Hide a SharePoint List View?

To hide a list view in SharePoint, use this PowerShell script:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Config variables
$ViewName="All Projects"

#Get the View
$Web = Get-SPWeb $SiteURL
$List = $Web.Lists[$ListName]
$View = $List.Views[$ViewName]

#Hide the list view

Write-host "List View Hidden from users!"

This hides the list view from users by hiding it from the view drop-down and list settings. However, if you know the URL, you can directly hit and get the view page!

SharePoint Online: Hide a List View using PowerShell

Similarly, in SharePoint Online hide list view, here is the PowerShell script.

#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= ""
$ViewName ="All Projects" 

#Get Credentials to connect
$Cred = Get-Credential
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
    #Get the List
    #Get the List View
    $ListView = $List.views.GetByTitle($ViewName)

    #Hide SharePoint Online List view
    $ListView.Hidden = $True

    Write-host -f Green "List View Hidden from users!"
Catch {
    write-host -f Red "Error Hiding List View!" $_.Exception.Message

This hides the list view in SharePoint Online from all users. If you want to restrict a view to specific users or groups, use another article: How to Set permission to SharePoint List View?

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

One thought on “How to Hide a List View in SharePoint using PowerShell?

  • is it possible to hide the view in SharePoint 2013 based on SharePoint groups? For instance hide the view for all ‘Site Visitors’ SharePoint group?


Leave a Reply

Your email address will not be published. Required fields are marked *