Reset SharePoint List View Filters with PowerShell

Requirement: Reset SharePoint view filters.

Solution: To reset SharePoint view in bulk, we can use this PowerShell script.

PowerShell script to reset SharePoint view:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$WebURL = "http://sales.crescent.com"
$ListName = "Proposal Documents"
$ViewName = "All Proposals"  
 
#Get the Site, List and View objects
$web = Get-SPWeb $WebURL
$List = $Web.Lists[$ListName]
$View = $List.Views | ? {$_.title -eq $ViewName}

#Reset SharePoint View - By default sort by Name
$View.Query = "<OrderBy><FieldRef Name='FileLeafRef' /></OrderBy>" 
$View.Update()
$List.Update()

This script removes Sorting and Filters applied to the given SharePoint list view.

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply