Reset filter on view using PowerShell

Summary: This post describes how to reset the filter on a view using PowerShell.

If you want to reset the filter for multiple views, you can use PowerShell to accomplish this.
Below is the script to do this for a single view:

#Variables
$web = "http://portal.contoso.com"
$listName = "Demo Library"
$viewName = "view2”

#Script
$lib = (Get-SPWeb $web).Lists[$listName]
$view = $lib.Views | ?{$_.title -eq $viewName}
$view.Query = '<OrderBy><FieldRef Name="FileLeafRef" /></OrderBy>'
$view.Update()
$lib.Update()

Make sure you change the variables to fit your environment.

Leave a Reply

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