Reset filter on 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()

This should do the trick.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s