1

I just got an insane request dropped onto my desk. On our site we have a section with 15 subsites, each subsite has 5 libraries.

The request was to add a new view with a new column to all of the libraries. Is there anyway to apply the view to all the libraries at once? Or am I looking at a long "fun" project?

They currently have the same columns but the views are not linked as a template or anything (not my doing)

We are using SharePoint 2013 and SharePoint Designer 2013 Thanks

0

You can try the below powershell

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

$siteURL = "http://sp14fdev01/"
$site = Get-SPSite($siteURL)

foreach($web in $site.AllWebs) {
  foreach($list in $web.Lists) {
    if($list.BaseType -eq "DocumentLibrary") {
// the variables `$web` and `$list` already reference the objects you need
      //$site = New-Object Microsoft.SharePoint.SPSite($SiteURL) ;
      //$web = $site.OpenWeb($SiteURL);

// new instance of the list is necessary to avoid the error "Collection was modified"
      $newList = $web.Lists.item($list.ID);

      $viewfields = New-Object System.Collections.Specialized.StringCollection 
      $viewfields.Add("DocIcon") 
      $viewfields.Add("LinkFilename") 
      $viewfields.Add("_UIVersionString") 
      $viewfields.Add("FileSizeDisplay") 
      $viewfields.Add("Created") 
      $viewfields.Add("Modified") 
      $viewfields.Add("Editor") 
      [void]$newList.Views.Add("Detailed", $viewfields, "", 100, $true, $true)

      $newList.Update();

// setting the default view
      $view=$newList.Views["Detailed"]
      $view.DefaultView = $true
      $view.Update()
    }
  }

  $web.Dispose();
}

$site.Dispose();

https://stackoverflow.com/questions/9980124/sharepoint-2010-powershell-loop-through-all-document-libraries-create-view-a

also check this:

How do I create a custom view and apply it to ALL document libraries on Sharepoint 2007 site

  • Finally getting back to this. It seems we don't have access to Powershell. Any other ideas on how to do this? Even if I had to rebuild all of the libraries so they had a shared/global view that could be updated later would be fine. – KurtH Jul 10 '15 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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