我有一个非常大的SharePoint文件夹,其中有许多嵌套的子文件夹,我试图在将该文件夹迁移到其他位置之前计算其中有多少项。
我有这个简单的脚本,但我总是得到这个错误时,每一个我试图计算一个文件夹,真的很大,所以只是想知道我如何才能增加阈值或解决这个问题。
$SiteURL = "https://company-my.sharepoint.com/personal/hello_nam_corp_com"
$searchfor = "/Documents/Archive"
$folderpath = "Documents/Archive"
$CSVFile = "C:\Users\Desktop\Resource\FolderStats.csv"
#Connect to SharePoint Online
Connect-PnPOnline $SiteURL -useWebLogin
#Get the list
#$documents = Get-PnPList -Identity $ListName | Where-Object {$_.Title -eq 'Documents'}
$FolderItems = Get-PnpListItem -List $folderpath
$fieldvalues = $FolderItems.Fieldvalues
$result = @()
foreach ($field in $fieldvalues) {
$obj = New-object psobject -property $field
$result += $obj.fileref
}
$final = $result | where-object {$_ -match $searchfor}
$item = New-Object psobject -Property @{
FolderName = Split-Path -Path $searchfor -Leaf
URL = $searchfor
filesfoldercount = $final.count
}
$item
$item | Export-Csv -Path $CSVFile -NoTypeInformation
Get-PnpListItem : The attempted operation is prohibited because it exceeds the list view threshold.
At line:13 char:16
+ $FolderItems = Get-PnpListItem -List $folderpath
2条答案
按热度按时间ljo96ir51#
试试下面的PowerShell。
脚本链接:https://www.sharepointdiary.com/2019/05/sharepoint-online-get-files-sub-folders-count-in-document-library-using-powershell.html
myss37ts2#
有点晚了,但仍然值得一提的是,你可以添加PageSize参数来返回指定大小的页面中的结果:
在您的示例中,您可以在此处添加以下内容:
更多信息:https://pnp.github.io/powershell/cmdlets/Get-PnPListItem.html