Skip to content

Instantly share code, notes, and snippets.

@Na0mir
Last active September 18, 2015 11:02
Show Gist options
  • Save Na0mir/cdc9c2aefe277a96a701 to your computer and use it in GitHub Desktop.
Save Na0mir/cdc9c2aefe277a96a701 to your computer and use it in GitHub Desktop.
Edit all views in a single site collection
# ----------------------------------------------
# Author: Romain Blanchard
# Date: 11.08.2015
# Description: Edit all views in a single site collection
# ----------------------------------------------
Add-PSSnapin Microsoft.SharePoint.Powershell
$SiteUrl = "http://mycpdintg.intg2013.dpgp.emea.loreal.intra/sites/ipanel"
$ViewName = "Published Folders"
$site = Get-SPSite $SiteUrl
foreach ($web in $site.AllWebs)
{
for($i=0;$i -lt $web.Lists.Count;$i++)
{
$views = $web.Lists[$i].Views | Where {$_.Title -eq $ViewName}
foreach ($view in $views)
{
$view.Query = $view.Query.Replace('$Resources:MyCPDResources,FIELDS_iPanelAlertsIsReady_ValueReady;','Published')
$view.Update()
}
}
}
Write-Host "Done !" -ForegroundColor Yellow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment