Skip to content

Instantly share code, notes, and snippets.

@joerodgers
Created November 21, 2019 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joerodgers/b0d86fdcee978ea585cdc6f92304f3c6 to your computer and use it in GitHub Desktop.
Save joerodgers/b0d86fdcee978ea585cdc6f92304f3c6 to your computer and use it in GitHub Desktop.
Gets the total item count of all items in a SharePoint 2013+ content database.
$sites = Get-SPSite -Limit All -ContentDatabase "SP2016_CONTENT_001"
$itemCounts = @()
foreach( $site in $sites )
{
$itemCount = 0
$lists = $site | Get-SPWeb -Limit All | SELECT -ExpandProperty Lists
$itemCounts += [PSCustomObject]@{
Site = $site.Url
TotalItems = $lists | Measure-Object -Property ItemCount -Sum | SELECT -ExpandProperty Sum
}
$site.Dispose()
}
$itemCounts
"`n`nTotal Items: $($itemCounts | Measure-Object -Property TotalItems -Sum | SELECT -ExpandProperty Sum)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment