Partager via


Total number of list items in a SharePoint Web Application

Ever wondered, how many list items you have in a Web Application?

You can use this Windows PowerShell script to know the total number of list items in a SharePoint Web Application. You can tweak the recursion to get list item details for subsite o for site collection level...

 

Below is the sample script.

 

if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
 {Add-PSSnapin Microsoft.SharePoint.Powershell}
 
$SPWebApp = Get-SPWebApplication("https://intranet.contoso.com")
 
$i=0
foreach ($SPSite in $SPWebApp.Sites)
{
    Write-Host "Going thru Site Collection" $SPSite.Title
    foreach ($SPWeb in $SPSite.AllWebs)
    {
        Write-Host "Going thru Web" $SPWeb.Title
        foreach ($SPList in $SPWeb.Lists)
        {
        Write-Host "Going thru List" $SPList.Title "which has" $SPList.ItemCount "item(s)"
        foreach ($SPListItem in $SPList.Items)
        {
            Write-Host "Going thru Item" $SPListItem.Name
            $i=$i+1
            }
        }
        $SPWeb.dispose()
    }
    $SPSite.dispose()
}
Write-Host "Total item count" $i

Comments

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    realy nice! thx

  • Anonymous
    January 01, 2003
    Great Job! :D

  • Anonymous
    January 01, 2003
    Thank you very much! How I can I run this in MOOS 2007? I have PowerShell installed already but I get error

  • Anonymous
    January 30, 2013
    Nice blog

  • Anonymous
    September 28, 2013
    The SPWeb was not defined in earlier statement. You mean $SPSite.Title ? Write-Host "Going thru Site Collection" $SPWeb.Title -thx

  • Anonymous
    November 17, 2013
    @Venkat: Thanks, corrected!