1

I want to change the current views (when you go to, for example, "Site Content > Pages") on Pages, Documents, Images libraries with a new set of columns so that all 100+ subsites in my site collection will all have a uniform set of columns when you go to view the Pages library (or Documents library, or Images library).

How should I go about doing this? For example when I go to mysite.sharepoint/Pages/Forms/AllItems.aspx

mysite.sharepoint/SUBSITE-1/Pages/Forms/AllItems.aspx

mysite.sharepoint/SUBSITE-1/SUBSITEOFSUBSITE/Pages/Forms/AllItems.aspx

mysite.sharepoint/SUBSITE-2/Pages/Forms/AllItems.aspx

I want all of these particular views to have the same set of columns.

Currently, all 100+ subsites have a varying assortment of columns.

Thanks, Sung

1 Answer 1

0

You can do this using PowerShell

  1. First get all Pages libraries in the Site Collection. For that you can use SPSiteDataQuery as explained in - List all Pages Libraries using PowerShell and SPSiteDataQuery?
  2. Once you have the Library object. You can modify the view as explained Updating a view using powershell

Final code will look something similar

$siteCollectionUrl = "http://sp2010"
$site =new-object Microsoft.SharePoint.SPSite($siteCollectionUrl)
$query = new-object Microsoft.SharePoint.SPSiteDataQuery
$query.Webs = "<Webs Scope='SiteCollection'>"
$query.Lists = "<Lists ServerTemplate='850' />"
$results = $site.rootweb.GetSiteData($query)
foreach($row in $results.rows)
{
  $listId = $row["ListId"]
  $webId = $row["WebId"]
  $childWeb = $site.OpenWeb([GUID]($webId))
  $pagesList = $childWeb.Lists[[GUID]($listId)];
  $view = $l.Views | ? { $_.Title -eq 'All items' }
  $view.ViewFields.Add($hereGoesFieldName);
  $view.Update();
  $childWeb.Dispose()
}
$site.Dispose()
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.