当前位置: 主页 > Office办公 > 其他专区 > SharePoint > 如何查询SharePoint Library中空文件夹?

如何查询SharePoint Library中空文件夹?

  • 2022-04-04
  • 来源/作者: 菜鸟图库/ 菜鸟图库
  • 283 次浏览

企业在使用SharePoint过程中,都会因为各种需求考虑对SharePoint做升级。而在升级之前我们都知道要对源端数据作分析,此时经常会被问到“在我的Library中有多少文件夹下面没有文件?”,对此进行了script查询整理和验证,具体请参考下面。

  • Script
if($TestSPSnapin-eq $null){
    add-pssnapin -NameMicrosoft.SharePoint.Powershell #-ErrorAction SilentlyContinue
    # SilentlyContinue is only good forinteractive console where you're sure of each command you're running.Otherwise, the script should block execution on snapin load failure.
}

functionCheckFolderContents ($folder)
{
$folderContent = "Folder at URL "+ $folder.Url + " has " + $folder.Files.Count + " files and" + $folder.SubFolders.Count + " subfolders.`n"
Add-Content C:\FolderContents.txt $folderContent
foreach($subfolder in $folder.SubFolders)
    {
        if ($subfolder.item -ne $null) # thedefault "Forms" folder has a null Item, and we don't need to includethe default "Forms" folder as part of this
        {
            CheckFolderContents $subfolder
        }
    }
}

## MAIN
$web =Get-SPWeb http://SharePointSiteCollectionURL
$list =$web.Lists["LibraryName"]
CheckFolderContents$list.RootFolder
$web.Dispose()

 

在执行完成后会在具体路径下生成report。

如何查询SharePoint Library中空文件夹?