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

【如何查询SharePoint Library中空文件夹?】分享给互联网技能从业者学习和参考。

企业在使用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 $folderContentforeach($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中空文件夹?