Get count of SharePoint List or Document Library Items using PowerShell


PowerShell script/code to get SharePoint List Item count

The same script works for both lists and libraries. You can add filters to get only specific items.

It is recommened to use variables so you can quickly modify the values and reuse script for any other site, list, library.

$siteUrl = "http://siteurl"
$listName = "[Name of List/Library]"
$spWeb = Get-SPWeb $siteUrl
$spList= $spWeb.Lists[$listName]

$items = $spList.Items.Count

The var $items will get the count value (Items.Count). Print the value to verify and then you can use it further in your logic.






Recent Posts:
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.