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.