Created
November 21, 2019 19:16
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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