Frage

Is there a way with SharePoint online in 2021 and SharePoint 2013, to easily find out how many documents are stored within a single document library? Same kind of question, two different approaches I am assuming.

War es hilfreich?

Lösung

Server:

$web = Get-SPWeb https://webUrl
$list = $web.Lists['Doc Lib Display Name']
$list.ItemCount

Online:

Connect-PnPOnline https://tenantName.sharepoint.com/sites/siteName
$list = Get-PnPList 'Doc Lib Display Name'
$list.ItemCount

Andere Tipps

SharePoint Online: Get Files, Sub-Folders Count at Each Folder in a Document Library using PowerShell

#Parameters
$SiteURL = "https://test.sharepoint.com/sites/projects"
$ListName = "Documents"
 
#Function to get number of Sub-folder and Files count recursively
Function Get-SPOFolderStats
{
    [cmdletbinding()]
    param
    (
        [Parameter(Mandatory=$true,ValueFromPipeline=$true)][Microsoft.SharePoint.Client.Folder]$Folder
    )
    #Get Sub-folders of the folder
    Get-PnPProperty -ClientObject $Folder -Property ServerRelativeUrl, Folders | Out-Null
 
    #Get the SiteRelativeUrl
    $Web = Get-PnPWeb -Includes ServerRelativeUrl
    $SiteRelativeUrl = $Folder.ServerRelativeUrl -replace "$($web.ServerRelativeUrl)", ""
 
    [PSCustomObject] @{
        Folder    = $Folder.Name
        Path      = $Folder.ServerRelativeUrl
        ItemCount = Get-PnPFolderItem -FolderSiteRelativeUrl $SiteRelativeUrl -ItemType File | Measure-Object | Select -ExpandProperty Count
        SubFolderCount = Get-PnPFolderItem -FolderSiteRelativeUrl $SiteRelativeUrl -ItemType Folder | Measure-Object | Select -ExpandProperty Count
    }
     
    #Process Sub-folders
    ForEach($SubFolder in $Folder.Folders)
    {
        Get-SPOFolderStats -Folder $SubFolder
    }
}
 
#Connect to SharePoint Online
Connect-PnPOnline $SiteURL -Credentials (Get-Credential)
 
#Call the Function to Get the Library Statistics - Number of Files and Folders at each level
$FolderStats = Get-PnPList -Identity $ListName -Includes RootFolder | Select -ExpandProperty RootFolder | Get-SPOFolderStats | Sort Path
$FolderStats
 
#Export to CSV
#$FolderStats | Export-Csv -Path "C:\Temp\DocLibStats.csv" -NoTypeInformation

enter image description here

SharePoint 2013: Get Files, Folders Count in a Document Library using PowerShell

$fileCount = 0
$folderCount = 0
$itemcount = 0

$Web = Read-host “Please enter the SPWEB Url”
$WebObject = get-spweb -Identity $Web
#$WebObject.Lists | Select Title
$Library = Read-Host “Please enter the Library or list name”
$LibraryObject = $WebObject.Lists[“$Library”]

$itemcount = $LibraryObject.ItemCount

foreach ($folders in $LibraryObject.Folders)
{
$folder = $folders.Folder
$folderCount ++

    foreach ($file in $folder.Files)
    {
        $fileCount ++
        $filesizeinkb = ($file.length/1024)
        “{0}`t{1}`t{2}” -f $folder.Name, $file.Name, $filesizeinkb   | out-file C:\SpFileExport.csv -Append     
    }
   
}
Write-Host -ForegroundColor Green “Total Item Count ” $itemcount
Write-Host -ForegroundColor Green “Total File Count ” $fileCount
Write-Host -ForegroundColor Green “Total Folder Count ” $folderCount

$WebObject.Dispose()

enter image description here

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top