[玩转系统] SharePoint Online:查找超过列表视图阈值限制 5000 的所有文件夹
作者:精品下载站 日期:2024-12-14 15:36:07 浏览:14 分类:玩电脑
SharePoint Online:查找超过列表视图阈值限制 5000 的所有文件夹
问题:任何 SharePoint 列表、库或文件夹包含超过 5000 个同一级别的项目,结果列表视图阈值超出 SharePoint Online 中的错误消息。虽然 SharePoint Online 列表或库中可以存储的项目或文件的最大数量为 3000 万个,但同一级别不能存储超过 5000 个项目。它们必须分类到子文件夹中!如果不,
- 当您尝试在“文件资源管理器”视图中打开时,您会看到“此文件夹为空”消息,尽管该文件夹中有内容。
如果您尝试使用 SharePoint 设计器导航到这些容器,您将收到“服务器错误:尝试的操作被禁止,因为它超出了管理员强制执行的列表视图阈值。”
- 如果您浏览这些库或文件夹,您将收到以下错误消息之一“出现问题。请重试或刷新页面”。
因此,为了主动避免最终用户问题,我们希望找到包含 5000 个项目的所有文件夹(包括列表或库的根文件夹和子文件夹)。
PowerShell 查找 SharePoint Online 中包含超过 5000 个项目的所有文件夹:
此 PowerShell 脚本扫描给定网站集,以查找在同一级别存储了超过 5000 个项目的文件夹。
#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Funds"
$ListviewThreshold = 5000
$CSVPath = "C:\Temp\ListviewThreshold.csv"
$Global:ListviewInventory = @()
$Pagesize = 2000
#Function to audit list view threshold
Function Audit-ListviewThreshold
{
[cmdletbinding()]
param([parameter(Mandatory = $true, ValueFromPipeline = $true)] $Web)
Write-host "Scanning Large Lists on Site '$($Web.URL)'"
#Get All Large Lists from the Web - Exclude Hidden and certain lists
$ExcludedLists = @("Form Templates", "Preservation Hold Library","Site Assets", "Pages", "Site Pages", "Images",
"Site Collection Documents", "Site Collection Images","Style Library")
$Lists= Get-PnPProperty -ClientObject $Web -Property Lists
$LargeLists = $Lists | Where-Object {$_.Hidden -eq $False -and $_.Title -notin $ExcludedLists -and $_.ItemCount -gt $ListviewThreshold}
#Process all large lists
$LargeLists | ForEach-Object {
$Folder = Get-PnPProperty -ClientObject $_ -Property RootFolder
Write-host "`tAuditing Items at List '$($Folder.ServerRelativeUrl)'" -f Yellow
#Check the Root Folder
If($Folder.ItemCount -gt $ListviewThreshold)
{
Write-host "`t`tFound a Folder with '$($Folder.ItemCount)' Items at '$($Folder.ServerRelativeURL)'" -f Green
#Collect data
$global:ListviewInventory += New-Object PSObject -Property ([ordered]@{
SiteURL = $Web.URL
FolderName = $Folder.Name
URL = $Folder.ServerRelativeUrl
ItemCount = $Folder.ItemCount
})
}
#Get Folders from List
$global:counter = 0;
$LargeFolders = Get-PnPListItem -List $_ -PageSize $Pagesize -Fields ItemChildCount,FolderChildCount -ScriptBlock { Param($items) $global:counter += $items.Count; Write-Progress -PercentComplete ($global:Counter / ($_.ItemCount) * 100) -Activity "Getting List Items of '$($_.Title)'" -Status "Processing Items $global:Counter to $($_.ItemCount)";} | Where {$_.FileSystemObjectType -eq "Folder"}
#Process all large folders in the list
$LargeFolders | ForEach-Object {
#Get the Item count in Folder
$ItemsCount = [int]$_.FieldValues.ItemChildCount
$SubfoldersCount = [int]$_.FieldValues.FolderChildCount
$ItemCount = $ItemsCount + $SubfoldersCount
If($ItemCount -gt $ListviewThreshold)
{
Write-host "`t`tFound a Folder with '$ItemCount' Items at '$($_.FieldValues.FileRef)'" -f Green
#Collect data
$global:ListviewInventory += New-Object PSObject -Property ([ordered]@{
SiteURL = $Web.URL
FolderName = $_.FieldValues.FileLeafRef
URL = $_.FieldValues.FileRef
ItemCount = $ItemCount
})
}
}
}
}
#Connect to Site collection
Connect-PnPOnline -Url $SiteURL -Interactive
#Iterate through all webs in the site collections and call the function
Get-PnPSubWeb -Recurse -IncludeRootWeb | ForEach-Object { Audit-ListviewThreshold $_ }
#Export Documents Inventory to CSV
$Global:ListviewInventory | Export-Csv $CSVPath -NoTypeInformation
使用 PnP PowerShell 在租户级别审核文件夹项目计数:
这次,让我们审核整个租户中网站集中的所有文件夹。
#Parameters
$Domain = "CrescentIntranet" #Domain Name in SharePoint Online. E.g. https://Crescent.sharepoint.com
$ListviewThreshold = 4000
$CSVPath = "C:\Temp\ListviewThreshold.csv"
$Global:ListviewInventory = @()
$Pagesize = 2000
#Frame Tenant URL and Tenant Admin URL
$TenantURL = "https://$Domain.SharePoint.com"
$TenantAdminURL = "https://$Domain-Admin.SharePoint.com"
#Function to audit list view threshold
Function Audit-ListviewThreshold
{
[cmdletbinding()]
param([parameter(Mandatory = $true, ValueFromPipeline = $true)] $Web)
Write-host "Scanning Large Lists on Site '$($Web.URL)'"
#Get All Large Lists from the Web - Exclude Hidden and certain lists
$ExcludedLists = @("Form Templates", "Preservation Hold Library","Site Assets", "Pages", "Site Pages", "Images",
"Site Collection Documents", "Site Collection Images","Style Library")
$Lists= Get-PnPProperty -ClientObject $Web -Property Lists
$LargeLists = $Lists | Where-Object {$_.Hidden -eq $False -and $_.Title -notin $ExcludedLists -and $_.ItemCount -gt $ListviewThreshold}
#Process all large lists
$LargeLists | ForEach-Object {
$Folder = Get-PnPProperty -ClientObject $_ -Property RootFolder
Write-host "`tAuditing Items at List '$($Folder.ServerRelativeUrl)'" -f Yellow
#Check the Root Folder
If($Folder.ItemCount -gt $ListviewThreshold)
{
Write-host "`t`tFound a Folder with '$($Folder.ItemCount)' Items at '$($Folder.ServerRelativeURL)'" -f Green
#Collect data
$global:ListviewInventory += New-Object PSObject -Property ([ordered]@{
SiteURL = $Web.URL
FolderName = $Folder.Name
URL = $Folder.ServerRelativeUrl
ItemCount = $Folder.ItemCount
})
}
#Get Folders from List
$global:counter = 0;
$LargeFolders = Get-PnPListItem -List $_ -PageSize $Pagesize -Fields ItemChildCount,FolderChildCount -ScriptBlock { Param($items) $global:counter += $items.Count; Write-Progress -PercentComplete ($global:Counter / ($_.ItemCount) * 100) -Activity "Getting List Items of '$($_.Title)'" -Status "Processing Items $global:Counter to $($_.ItemCount)";} | Where {$_.FileSystemObjectType -eq "Folder"}
Write-Progress -Activity "Completed Retrieving Items from List $($Folder.ServerRelativeUrl)" -Completed
#Process all large folders in the list
$LargeFolders | ForEach-Object {
#Get the Item count in Folder
$ItemsCount = [int]$_.FieldValues.ItemChildCount
$SubfoldersCount = [int]$_.FieldValues.FolderChildCount
$ItemCount = $ItemsCount + $SubfoldersCount
If($ItemCount -gt $ListviewThreshold)
{
Write-host "`t`tFound a Folder with '$ItemCount' Items at '$($_.FieldValues.FileRef)'" -f Green
#Collect data
$global:ListviewInventory += New-Object PSObject -Property ([ordered]@{
SiteURL = $Web.URL
FolderName = $_.FieldValues.FileLeafRef
URL = $_.FieldValues.FileRef
ItemCount = $ItemCount
})
}
}
}
}
#Connect to Admin Center
Connect-PnPOnline -Url $TenantAdminURL -Interactive
#Get All Site collections - Filter BOT and MySite Host
$Sites = Get-PnPTenantSite -Filter "Url -like '$TenantURL'"
#Iterate through all site collections
$Sites | ForEach-Object {
#Connect to each site collection
Connect-PnPOnline -Url $_.URL -Interactive
#Iterate through all webs in the site collections and call the function
Get-PnPSubWeb -Recurse -IncludeRootWeb | ForEach-Object { Audit-ListviewThreshold $_ }
}
#Export Documents Inventory to CSV
$Global:ListviewInventory | Export-Csv $CSVPath -NoTypeInformation
我有关 SharePoint Online 中的列表视图阈值的相关帖子 - 常见问题解答
猜你还喜欢
- 03-30 [玩转系统] 如何用批处理实现关机,注销,重启和锁定计算机
- 02-14 [系统故障] Win10下报错:该文件没有与之关联的应用来执行该操作
- 01-07 [系统问题] Win10--解决锁屏后会断网的问题
- 01-02 [系统技巧] Windows系统如何关闭防火墙保姆式教程,超详细
- 12-15 [玩转系统] 如何在 Windows 10 和 11 上允许多个 RDP 会话
- 12-15 [玩转系统] 查找 Exchange/Microsoft 365 中不活动(未使用)的通讯组列表
- 12-15 [玩转系统] 如何在 Windows 上安装远程服务器管理工具 (RSAT)
- 12-15 [玩转系统] 如何在 Windows 上重置组策略设置
- 12-15 [玩转系统] 如何获取计算机上的本地管理员列表?
- 12-15 [玩转系统] 在 Visual Studio Code 中连接到 MS SQL Server 数据库
- 12-15 [玩转系统] 如何降级 Windows Server 版本或许可证
- 12-15 [玩转系统] 如何允许非管理员用户在 Windows 中启动/停止服务
取消回复欢迎 你 发表评论:
- 精品推荐!
-
- 最新文章
- 热门文章
- 热评文章
[影视] 黑道中人 Alto Knights(2025)剧情 犯罪 历史 电影
[古装剧] [七侠五义][全75集][WEB-MP4/76G][国语无字][1080P][焦恩俊经典]
[实用软件] 虚拟手机号 电话 验证码 注册
[电视剧] 安眠书店/你 第五季 You Season 5 (2025) 【全10集】
[电视剧] 棋士(2025) 4K 1080P【全22集】悬疑 犯罪 王宝强 陈明昊
[软件合集] 25年6月5日 精选软件22个
[软件合集] 25年6月4日 精选软件36个
[短剧] 2025年06月04日 精选+付费短剧推荐33部
[短剧] 2025年06月03日 精选+付费短剧推荐25部
[软件合集] 25年6月3日 精选软件44个
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电视剧] 欢乐颂.5部全 (2016-2024)
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[影视] 【稀有资源】香港老片 艺坛照妖镜之96应召名册 (1996)
[剧集] 神经风云(2023)(完结).4K
[剧集] [BT] [TVB] [黑夜彩虹(2003)] [全21集] [粤语中字] [TV-RMVB]
[实用软件] 虚拟手机号 电话 验证码 注册
[资源] B站充电视频合集,包含多位重量级up主,全是大佬真金白银买来的~【99GB】
[影视] 内地绝版高清录像带 [mpg]
[书籍] 古今奇书禁书三教九流资料大合集 猎奇必备珍藏资源PDF版 1.14G
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电影] 美国队长4 4K原盘REMUX 杜比视界 内封简繁英双语字幕 49G
[电影] 死神来了(1-6)大合集!
[软件合集] 25年05月13日 精选软件16个
[精品软件] 25年05月15日 精选软件18个
[绝版资源] 南与北 第1-2季 合集 North and South (1985) /美国/豆瓣: 8.8[1080P][中文字幕]
[软件] 25年05月14日 精选软件57个
[短剧] 2025年05月14日 精选+付费短剧推荐39部
[短剧] 2025年05月15日 精选+付费短剧推荐36部
- 最新评论
-
- 热门tag