ค้นหาเว็บไซต์

SharePoint Online: ค้นหาโฟลเดอร์ทั้งหมดที่เกินขีดจำกัดมุมมองรายการ 5000


ปัญหา: รายการ SharePoint ไลบรารี หรือโฟลเดอร์ใด ๆ มีมากกว่า 5000 รายการในระดับเดียวกันรายการผลลัพธ์เกณฑ์เกินขีดจำกัดมุมมองรายการใน SharePoint Online แม้ว่าจำนวนรายการหรือไฟล์สูงสุดที่สามารถจัดเก็บในรายการหรือไลบรารี SharePoint Online คือ 30 ล้านรายการ แต่ไม่สามารถจัดเก็บรายการมากกว่า 5000 รายการในระดับเดียวกันได้ ต้องจัดหมวดหมู่เป็นโฟลเดอร์ย่อย! ถ้าไม่,

  • เมื่อคุณพยายามเปิดในมุมมอง "File Explorer" คุณจะเห็นข้อความ "โฟลเดอร์นี้ว่างเปล่า" แม้ว่าโฟลเดอร์นั้นจะมีเนื้อหาอยู่ก็ตาม
  • ถ้าคุณพยายามนำทางไปยังคอนเทนเนอร์เหล่านี้โดยใช้โปรแกรมออกแบบ SharePoint คุณจะได้รับ "ข้อผิดพลาดของเซิร์ฟเวอร์: การดำเนินการที่พยายามถูกห้าม เนื่องจากเกินเกณฑ์มุมมองรายการที่บังคับใช้โดยผู้ดูแลระบบ"

  • หากคุณเรียกดูไลบรารีหรือโฟลเดอร์เหล่านี้ คุณจะได้รับข้อความแสดงข้อผิดพลาดด้านล่างนี้ว่า “มีบางอย่างผิดพลาด โปรดลองอีกครั้งหรือรีเฟรชหน้าเว็บ”

ดังนั้น เพื่อหลีกเลี่ยงปัญหาสำหรับผู้ใช้ในเชิงรุก เราต้องการค้นหาโฟลเดอร์ทั้งหมด (รวมถึงโฟลเดอร์รากของรายการหรือไลบรารีและโฟลเดอร์ย่อย) ที่มี 5,000 รายการในนั้น

PowerShell เพื่อค้นหาโฟลเดอร์ทั้งหมดที่มีมากกว่า 5,000 รายการใน SharePoint Online:

สคริปต์ 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 - คำถามที่พบบ่อย

บทความที่เกี่ยวข้อง