← script library

Monitor SharePoint Site Usage with PowerShell

SharePoint & OneDriveJanuary 4, 2025

Keeping track of site usage in SharePoint is essential for managing storage and understanding user engagement. This PowerShell script helps you retrieve and display key usage statistics for SharePoint sites, including the number of visitors and storage consumption. By automating this report, you can maintain better oversight of your SharePoint environment.

powershell
# Install the SharePoint Online Management Shell if it is not already installed
Install-Module -Name "Microsoft.Online.SharePoint.PowerShell" -Force

# Connect to SharePoint Online
$siteUrl = "https://yourtenant.sharepoint.com/sites/yoursite"  # Replace with your SharePoint site URL
Connect-SPOService -Url $siteUrl

# Retrieve site usage data
$siteUsage = Get-SPOSite -Identity $siteUrl -Detailed | Select-Object Title, Owner, StorageUsageCurrent, StorageQuota, LastContentModifiedDate, LastItemUserModifiedDate

# Display the site usage results
$siteUsage | Format-Table -AutoSize

# Export the site usage data to a CSV file
$siteUsage | Export-Csv -Path "C:\SharePoint_Site_Usage_Report.csv" -NoTypeInformation

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.