How to: get a number of lists and lists items for SharePoint site collection

The fastest way to do it is to use following PS script:

Add-PSSnapin Microsoft.Sharepoint.Powershell

$ListsInfo = @{}

$TotalItems = 0

$SiteCollection = Get-SPSite "http://sitecollection.domain.com/"

ForEach ($Site in $SiteCollection.AllWebs)

{

ForEach ($List in $Site.Lists)

{

$ListsInfo.Add($Site.Url + " - " + $List.Title, $List.ItemCount)

$TotalItems += $List.ItemCount

}

}

$ListsInfo.GetEnumerator() | sort name | Format-Table -Autosize

Write-Host "Total number of Lists: " $ListsInfo.Count

Write-Host "Total number of ListItems: " $TotalItems

It will count all the lists and number items inside of these lists, plus output total lists number and total items number in all lists for site collection URL of which you specify in 4th line of this script. This script works both for SharePoint 2010 and 2013.

If you are on look out for script to generate some list items for testing purposes you may find exactly what you need in Cameron Dwyer’s blog, in the following post “SharePoint PowerShell How To: Create SharePoint List Items (in Root and in Folders) for Load/Performance Testing.”

Please follow and like us:
error0
Tweet 20
fb-share-icon20

1 thought on “How to: get a number of lists and lists items for SharePoint site collection

  1. Diego Gomez

    Hi MikeYour script is good, I know if you have one script like this, but accounting Items in each site and in alls site?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *