Recently, I got a requirement to display the SharePoint Online list item count. I used PnP PowerShell for this. In this tutorial, I will show you how to get the count of items in a SharePoint list using PnP PowerShell.
Get Count of Items in SharePoint List using PnP PowerShell
Let me show you different methods to get the count of items in a SharePoint list using PnP PowerShell.
Here, I have a SharePoint Online list to which I have added a few items. The screenshot below shows what the SharePoint list looks like.

We will see here how to get the SharePoint list item counts using PnP PowerShell.
1. Get List Item Count Using Get-PnPList
In PnP PowerShell, you can use the the ItemCount property of the list object to get the item count in SharePoint Online.
Here is a complete PnP PowerShell script, you can see.
# Connect to SharePoint Online
Connect-PnPOnline -Url "https://szg52.sharepoint.com/sites/PowerPlatformFAQs" -Interactive
# Get the list
$list = Get-PnPList -Identity "LargeInventoryList"
# Get the item count
$itemCount = $list.ItemCount
Write-Output "Total items in the list: $itemCount"Once you execute the above PowerShell script using VS code, you can see the SharePoint Online list item count like in the screenshot below. I executed the above script in my local system.

Read How to Check if a Folder Exists in SharePoint Online using PnP PowerShell
2. Get List Item Count Using Get-PnPListItem
The PnP PowerShell Get-PnPListItem cmdlet retrieves items from a SharePoint list. To get the count of items, you can use the -PageSize parameter to handle large lists efficiently.
Here is a complete PnP PowerShell script.
# Connect to SharePoint Online
Connect-PnPOnline -Url "https://szg52.sharepoint.com/sites/PowerPlatformFAQs" -Interactive
# Get the list
$list = Get-PnPList -Identity "LargeInventoryList"
# Get all items in the list
$items = Get-PnPListItem -List $list -PageSize 5000 -Fields "ID"
# Get the count of items
$itemCount = $items.Count
Write-Output "Total items in the list: $itemCount"This method is particularly useful if the list is large. I executed the above PowerShell script using VS code, and you can see the output in the screenshot below. It gives me the exact list of item counts.

Read Upload Files to a SharePoint Document Library using PnP PowerShell
3. Get Item Count from a Specific Folder
If you need to get the count of items in a specific folder within a SharePoint list or library, you can use the Get-PnPFolderItem PnP PowerShell cmdlet.
Here is a complete PowerShell script.
# Connect to SharePoint Online
Connect-PnPOnline -Url "https://szg52.sharepoint.com/sites/PowerPlatformFAQs" -Interactive
# Define the library and folder
$libraryName = "MyLibrary"
$folderPath = "/sites/PowerPlatformFAQs/MyLibrary/MyFolder"
# Get the items in the folder
$folderItems = Get-PnPListItem -List $libraryName -FolderServerRelativeUrl $folderPath -PageSize 5000
# Get the count of items in the folder
$itemCount = $folderItems.Count
Write-Output "Total items in the folder: $itemCount"The Get-PnPListItem cmdlet is used with the -FolderServerRelativeUrl parameter to specify the folder path. This retrieves all items within the specified folder.
I executed the above PnP PowerShell script, and you can see in the screenshot below it is giving the exact item count from a SharePoint Online list or library folder.

Conclusion
In this tutorial, I have explained how to get the count of items in a SharePoint list using PnP PowerShell. I have also explained how to count items in a large SharePoint Online list using PnP PowerShell. We also saw how to count items from a folder in a SharePoint list or document library using PnP PowerShell.
You may also like the following tutorials:
- PnP PowerShell CRUD Operation in SharePoint Online List
- Delete All Items from a SharePoint List using PnP PowerShell
- Import Data from Excel to SharePoint List using PnP PowerShell
- Copy Items from One List to Another in SharePoint Online Using PnP PowerShell
- Get SharePoint Online Site Details Using PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.