Count SharePoint List Items with PowerShell
Today I needed to know a quantity of SharePoint List. Somewhy SharePoint doen't give this information using common tools. But using PowerShell it appeared to do easy.
//add MS SharePoint Snapin for power shell if(!(Get-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction:SilentlyContinue)) { Add-PsSnapin Microsoft.SharePoint.PowerShell } $web = Get-SPWeb http://spdev/SiteWithListUrl/ $list = $web.Lists["ListName"] $listitems = $list.Items.Count Write-Host "Items in list: " $listitems
Never don’t do such terrible thing. $list.Items return all item collection. It’s a very heavy operation. Always return only with special SPList property ItemCount:
$listitems = $list.ItemCount
Comment by Vorant — October 8, 2014 @ 7:22 am
Thank you, I have already foorgotten about this record. I was young and didn’t know a lot
Comment by admin — October 8, 2014 @ 3:16 pm