Updated 1 week ago

Get List Item Count in SharePoint Online Using PowerShell

by Praba

6 min read

No Comments

In organizations, SharePoint lists are essential for organizing and managing various data, from tracking tasks to managing customer information and inventory. These lists not only streamline collaboration but also ensure that data is easily accessible and well-structured. However, as these lists expand over time, monitoring the number of list items becomes crucial for admins.

To get the total items count in SharePoint Online lists,

  1. Log in to the SharePoint admin center.
  2. Navigate to Sites –> Active sites and select the respective site.
  3. Click on the settings icon in the top-right corner.
  4. Select “Site contents” from the list.
  5. Now, you’ll see the number of items listed next to each list type.

Alternatively, you can execute the ‘Get-PnPList | Select Title, ItemCount command after connecting to SharePoint Online using PnP PowerShell.

Unfortunately, these methods have limitations. Admins must check each site individually, a process that is both time-consuming and prone to errors. To address this challenge, we’ve developed a PowerShell script that exports a comprehensive SharePoint Online list item count report. This script supports Certificate-Based Authentication (CBA), providing an automated solution that bypasses the need for direct credential use. With this approach, admins can easily obtain the data they need without the hassle of manually accessing each site and list.

Download Script: GetSPOListItemsCount.ps1

Script Highlights

  1. The script exports SharePoint Online lists and their items count in the organization.
  2. Provides the SPO list item count of a single site.
  3. Allows to retrieve SPO list items count of multiple sites using an input CSV.
  4. Helps to get the total list items count including hidden lists.
  5. Tracks the inactive lists and their item count in SharePoint.
  6. Automatically installs the PnP PowerShell module (if not installed already) upon your confirmation.
  7. The script can be executed with an MFA-enabled account too.
  8. Exports report results as a CSV file.
  9. The script is schedular-friendly.
  10. The script uses modern authentication to connect SharePoint Online
  11. It can be executed with certificate-based authentication (CBA) too.

Sample Output

The script exports SharePoint Online list items count report with the following attributes.

  • List Title
  • List URL
  • Item Count
  • Site Name
  • Last Item User Modified Date
  • Inactive Days
  • Author Name
  • Author Email
  • Created Time
  • Last Item Deleted Date
  • Is Hidden
  • Is Attachment Enabled
  • Default View URL
  • Site URL

The exported SharePoint Online list items count report looks like the screenshot below.

Get SPO list items count

Note: To ensure the script runs smoothly, please make sure to use PowerShell 7 or later. The script may not function as expected with earlier versions of PowerShell.

Export SharePoint Online List Item Count Report – Script Execution

  1. Download the script.
  2. Start the Windows PowerShell.
  3. You can choose any of the methods provided to execute the script.

Method 1: You can run the script with MFA and non-MFA accounts.

Since every SharePoint Online site has a storage limit, admins must know how many items are there in SPO lists to ensure that they have enough space for future growth.

When you run this script, you will be asked to enter your tenant’s name. The script will then fetch all SharePoint Online sites having lists and total count of items in them. This information is crucial for monitoring and managing your overall SPO storage utilization.

Important Tip: If you’re not a site admin, you might encounter “Unauthorized operation” or “Access is denied” errors when exporting the SharePoint Online list item count report. To avoid these issues, use the Certificate-Based Authentication (CBA) method as described below.

Method 2: Run the script using certificate-based authentication

You also have the option to run the script using certificate-based authentication. When you want to run the script unattended, you can choose this method. To use certificates, you must register an app in Microsoft Entra that help you connect to SPO using certificate.

Note: As this script is schedular-friendly, you can schedule this script using Task schedular or Azure Automation.

Make the Most Out of the Script:

The script includes customizable filtering options designed to meet your specific needs. Here’s a specific scenario where the script excels.


Get List Items Count for an Individual SharePoint Site

Need to analyze the item count for a particular site’s list? Run the script with the -SiteUrl parameter to get a clear picture of data volume for that site, allowing for better management and smooth project operations.

By running the above, you will obtain a report focusing on the specified site’s list items, aiding in targeted site management.

Note: In addition to counting SPO list items, you can use a similar PowerShell script to export document libraries in SharePoint Online along with their file and folder counts.

Export SharePoint Online List Item Count for Multiple Sites

Exporting list items count for important SPO sites helps admins keep track of crucial data and ensure the site runs smoothly. For example, if a key project site slows down because its task list is too large, exporting the item count can identify the problem. This lets admins fix issues quickly and keep everything working well.

Run the script by specifying the path of the created CSV file in the –ImportCsv parameter.

Remember that you should provide the list of required site URLs with a column name ‘SiteUrl’.

Sample Input:

SharePoint Online List Item Count for Multiple Sites

Note: You can also set up SharePoint Online alerts to notify you when new items are added, existing items are modified, or items are deleted from lists.

Generate the Total Count of Items Including the SPO Hidden Lists

Hidden SharePoint lists, whether system-generated or manually hidden, continue to consume storage space. To ensure efficient storage management and avoid exceeding limits, include these hidden lists in your total item count.

Execute the script with the –IncludeHiddenLists parameter to get SharePoint Online list item count along with hidden lists.

This ensures you get a complete item count, including all hidden lists.

If you want the list items count of only the hidden lists, then run the following along with -ShowHiddenListsOnly parameter.

Find Inactive Lists and their Items Count

Admins often need to monitor inactive SharePoint lists to keep their environments efficient and up-to-date. By identifying and managing these inactive lists, they can improve system performance and maintain a clean, relevant user experience.

To get the item count of inactive SharePoint lists, use the following script with the -Inactivedays parameter.

For example, executing the script with 100 days will fetch the SharePoint lists that have been inactive for over 100 days and their items count. Adjust the -Inactivedays parameter based on your needs.

Schedule the SharePoint Online List Item Count Report

Scheduling this report is crucial for admins to keep an up-to-date check on SharePoint list item counts, helping identify issues promptly.

Opt for CBA when you need a secure, automated process that avoids direct credential use.

Note: Beyond just the lists, it’s equally important to monitor storage utilization for files and folders within your SharePoint Online environment. To get a complete view of your storage usage, consider to export SharePoint Online file and folder storage report using PowerShell.

Simplify SharePoint Online Lists Management with AdminDroid

Effectively monitoring SharePoint Online lists and their count through PowerShell can be tiresome and time-consuming task, when you have to manage a large number of SPO lists. AdminDroid steps in as a comprehensive solution, offering crystal-clear insights with its extensive suite of SharePoint Online reporting.

Reports offered by AdminDroid on SharePoint Online Lists includes:

  • All SharePoint Lists
  • Hidden SharePoint Lists
  • Inactive SharePoint Lists
  • Empty SharePoint Lists
  • SharePoint Lists with IRM Enabled
  • SharePoint Lists with No Versioning
  • SharePoint Lists with Attachment Enabled
  • SharePoint Lists with Custom Permission

SharePoint Online List Report by AdminDroid

Moreover, AdminDroid’s SharePoint Online auditing tool ensures you stay on top of your site’s activities, enhancing security and administration with ease. By providing real-time insights and detailed reports, it empowers you to make informed decisions and swiftly address potential issues. This comprehensive approach enhances your SharePoint Online management and ensures robust site security.

Ready to take your Office 365 management to the next level? AdminDroid is your all-in-one solution! With more than 1800 detailed reports and over 30 interactive dashboards. It covers key areas including reporting, auditing, analytics, usage statistics, and security & compliance. With AdminDroid, you can efficiently manage Exchange Online, SharePoint Online, Microsoft Teams, OneDrive for Business, and more.

Take advantage of a 15-day free trial to experience the AdminDroid difference. Download AdminDroid today and start optimizing your Microsoft 365 environment!

I hope this blog helped you gain the items counts in SPO lists at ease. Feel free to reach us through the comments section if you have any queries.

Share article