Today, in this article we are going to see how
to find out how may documents are in your document libraries on a particular
SharePoint site? You can use this script to point to a particular site, or even
the root site, and get that information quickly and easily.
1. Download the script and save as
Get-SPDocumentCount.ps1
2. Edit the file and change the PARAM
section and change $RootSite to the root URL of your SharePoint site.
3. Edit $ReportPath to where you want the
script to save your report and save the file.
** IMPORTANT **
Script must be run on your SharePoint
server.
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges({
Param (
[Parameter(Mandatory=$true)]
[string]$Site,
[string]$RootSite = "https://test.portal/lobalcr/eam",
[string]$ReportPath = "c:\reports"
)
Add-PSSnapin
Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$Webs = Get-SPWeb -Site $RootSite -Filter {
$_.Template -like "*" } -Limit ALL | Where { $_.URL -like
"$Site*" }
$Result = @()
ForEach ($Web in $Webs)
{
ForEach ( $List in $Web.Lists )
{ $Result += New-Object PSObject
-Property @{
'Library Title' = $List.Title
Count = $List.Items.Count
'Site Title' = $Web.Title
URL = $Web.URL
'Library Type' = $List.BaseType
}
}
}
$Result | Select 'Site Title',URL,'Library
Type','Library Title',Count | Export-Csv
"$ReportPath\SPListReport.csv" -NoTypeInformation
});
No comments:
Post a Comment