List of active sites in Tenant with Admins and storage used
Summary
This script provides you the list of active sites in your tenant with their administrator and usage in MB.
Connect-PnPOnline -Url "https://contoso-admin.sharepoint.com/" -Interactive
# Get all SharePoint sites
$sites = Get-PnPTenantSite
# Create an array to store the results
$results = @()
# Iterate through each site and gather required information
foreach ($site in $sites) {
$siteUrl = $site.Url
Connect-PnPOnline -Url $siteUrl -Interactive
# Get site administrators
$admins = Get-PnPSiteCollectionAdmin | Select-Object -ExpandProperty Title
# Get site storage size
$storageSize = Get-PnPTenantSite -Url $siteUrl | Select-Object -ExpandProperty StorageUsageCurrent
# Create a custom object with the site information
$siteInfo = [PSCustomObject]@{
SiteUrl = $siteUrl
Administrators = $admins -join ";"
StorageSize = $storageSize.ToString() +" MB(s)"
}
# Add the site information to the results array
$results += $siteInfo
}
# Output the results as a CSV file
$results | Export-Csv -Path "SiteInventory.csv" -NoTypeInformation
# Disconnect from SharePoint Online
Disconnect-PnPOnline
Check out the PnP PowerShell to learn more at: https://aka.ms/pnp/powershell
The way you login into PnP PowerShell has changed please read PnP Management Shell EntraID app is deleted : what should I do ?
Contributors
Author(s) |
---|
Diksha Bhura |
Disclaimer
THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.