lundi 23 mars 2015

Programatically filtering SharePoint 2010 lists that may have files by base templates



Hope this will find an answer and will be useful for somebody else looking for the same solution.


I have identified the following list types and their respective BaseTemplates (see text in quotes) as those type of lists where users can upload files to:



  1. Documents Library: "DocumentLibrary"

  2. Asset Library: "851"

  3. Report Library: "433"

  4. Picture Library: "109"


My code reflects the definitions above:



$siteURL = "http://yoursite"
$site = new-object Microsoft.Sharepoint.SPSite($siteURL)
$webApp = $site.WebApplication
$allSites = $webApp.Sites
foreach ($site in $allSites)
{
$allWebs = $site.AllWebs
foreach ($web in $allWebs)
{
$lists = $web.Lists
foreach($list in $lists)
{
#Getting the base template of each list found
$ListBaseTemplate = $list.BaseTemplate

#Filtering lists where users can upload files to
if($ListBaseTemplate = "DocumentLibrary" -or $ListBaseTemplate = "851" -or $ListBaseTemplate = "433" -or $ListBaseTemplate = "109")
{
#I think I am not missing any uploaded file to our SharePoint
foreach ($item in $list.items)
{
#Getting file properties
}
}
}
}
}


My question is if this code could miss files uploaded to SharePoint 2010








0 commentaires:

Enregistrer un commentaire