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:

$web = ""
$listName = "Demo Library"
$viewName = "view2”

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

Make sure you change the variables to fit your environment.

Leave a Reply

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