How to Retrieve SharePoint Site Usage Statistics Programmatically
Question details
The user is attempting to retrieve SharePoint site usage statistics using PowerShell, but the relevant search properties fail to output actual data.

- Product
- Microsoft SharePoint
- Device & OS
- not provided
- Scenario
- Using PowerShell and SharePoint Search properties to programmatically pull usage statistics and unique user views.
- Observed behavior
- Search properties such as ViewsLifeTime, ViewsLifeTimeUniqueUsers, and ViewsRecent return zero. The built-in analytics page only provides limited data for popular documents from the previous seven days.
Ensure you have the appropriate SharePoint administrator permissions and the latest version of the SharePoint Online Management Shell installed before executing administrative scripts.
Consult the Microsoft Q&A Community for PowerShell Scripting
Because programmatic reporting involves advanced PowerShell and SharePoint Search customization, escalating the issue to specialized Microsoft developers is the most effective approach.
SharePoint APIs and Search properties undergo frequent updates, which can cause scripts relying on properties like ViewsLifeTime to unexpectedly return zero. Expert guidance from the Microsoft community helps identify deprecated APIs or missing search schema mappings.
Open your web browser and go to the official Microsoft Q&A platform at learn.microsoft.com/en-us/answers.
Use the search bar to locate and select the 'SharePoint' or 'SharePoint Development' tags to ensure your query reaches the right experts.
Submit a detailed question. Include your current PowerShell script and specify that properties like ViewsLifeTime and ViewsRecentUniqueUsers are returning zero despite site activity.

Verify Native SharePoint Site Usage Reports
Before deploying complex PowerShell scripts, confirm that your site is actively logging traffic in the default SharePoint Analytics dashboard.
Manage Your Documents Seamlessly with WPS Office
While SharePoint handles complex site analytics and deployments, you may need a reliable, lightweight suite for creating and editing your reports locally. WPS Office offers excellent compatibility with Microsoft formats without the heavy enterprise overhead.
- 1. Download the Installer: Visit the official WPS Office website and download the free installer for your operating system.
- 2. Install WPS Office: Run the setup file and follow the quick on-screen instructions to install the suite.
- 3. Open Microsoft Documents: Launch WPS Office and directly open your downloaded SharePoint documents (.docx, .xlsx, .pptx) with zero formatting loss.

Frequently Asked Questions
Why do SharePoint ViewsLifeTime properties return 0 in PowerShell?
This commonly occurs if the SharePoint search schema has not been crawled recently, if the managed properties are not properly mapped to the crawled properties, or if the specific tracking APIs have been updated or restricted in SharePoint Online.
How far back does the default SharePoint Analytics page track data?
The standard built-in site usage page focuses on recent activity and popular documents, typically displaying data limited to the past 7, 30, or 90 days depending on the specific metric being viewed.
Can I use Microsoft Graph API instead of PowerShell for SharePoint statistics?
Yes. Microsoft Graph API is currently the modern, recommended approach for programmatic access to Microsoft 365 data, offering more robust endpoints for retrieving detailed site analytics and usage reports.




