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" -NoTypeInformationRun 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.
More in SharePoint & OneDrive
Streamline SharePoint File Permissions Management with PowerShell
2025-01-04Managing File Permissions in SharePoint with PowerShell
2025-01-04Automate User Permissions Management in SharePoint with PowerShell
2024-12-24Efficiently List User Permissions in SharePoint with PowerShell
2024-12-24Efficiently Manage OneDrive File Permissions with PowerShell
2024-12-24Streamline File and Folder Permissions Management in SharePoint with PowerShell
2024-12-24Ready when you are.
Try ServerEngine free for 7 days.