Requirement: Need to generate a report to analyze all SharePoint Online Site collection storage consumption.
How to get the Storage Metrics of a SharePoint Online Site Collection?
To find the storage details of a site collection, Go to:
This page gives SharePoint Online site collection storage details along with the breakdown of data usage.
Get Storage Info for a Single Site Collection using PowerShell:
Lets use PowerShell script to get the storage size allocated, used and warning level of a given site collection.
This PowerShell retrieves SharePoint online site collection quota in MBs.
SharePoint Online: Site Collection Size Report using PowerShell
This PowerShell script gets storage details such as Total Size allocated, Consumption of all site collections in SharePoint Online.
Here is the CSV file generated by the script to give an overview of the storage usage of all site collections in your tenant:
Using PowerShell-CSOM to get Storage details of a Site Collection:
Other than SharePoint Online Management Shell, You can also use CSOM way as an alternate to retrieve storage size metrics of a site collection.
#Read more: http://www.sharepointdiary.com/2017/04/sharepoint-online-get-storage-size-quota-report-using-powershell.html#ixzz5Pf0sRNH5
How to get the Storage Metrics of a SharePoint Online Site Collection?
To find the storage details of a site collection, Go to:
- Click on Settings gear and then select Site Settings.
- In the "Site Settings" page, under "Site Collection Administration", click on Storage Metrics.
This page gives SharePoint Online site collection storage details along with the breakdown of data usage.
Get Storage Info for a Single Site Collection using PowerShell:
Lets use PowerShell script to get the storage size allocated, used and warning level of a given site collection.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| #Config Parameters $AdminSiteURL = "https://crescent-admin.sharepoint.com" $SiteURL = "https://crescent.sharepoint.com/sites/Ops" #Get Credentials to connect to SharePoint Admin Center $Cred = Get-Credential #Connect to SharePoint Online Admin Center Connect -SPOService -Url $AdminSiteURL –Credential $Cred #Get the Site collection $Site = Get -SPOSite $SiteURL Write-Host "Allocated:" $Site .StorageQuota Write-Host "Used:" $Site .StorageUsageCurrent Write-Host "Warning Level:" $Site .StorageQuotaWarningLevel |
This PowerShell retrieves SharePoint online site collection quota in MBs.
SharePoint Online: Site Collection Size Report using PowerShell
This PowerShell script gets storage details such as Total Size allocated, Consumption of all site collections in SharePoint Online.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| #Config Parameters $AdminSiteURL = "https://crescent-admin.sharepoint.com" $ReportOutput = "C:\Temp\SPOStorage.csv" #Get Credentials to connect to SharePoint Admin Center $Cred = Get-Credential #Connect to SharePoint Online Admin Center Connect -SPOService -Url $AdminSiteURL –Credential $Cred #Get all Site collections $SiteCollections = Get -SPOSite -Limit All Write-Host "Total Number of Site collections Found:" $SiteCollections .count -f Yellow #Array to store Result $ResultSet = @() Foreach ( $Site in $SiteCollections ) { Write-Host "Processing Site Collection :" $Site .URL -f Yellow #Send the Result to CSV $Result = new-object PSObject $Result | add-member -membertype NoteProperty -name "SiteURL" -Value $Site .URL $Result | add-member -membertype NoteProperty -name "Allocated" -Value $Site .StorageQuota $Result | add-member -membertype NoteProperty -name "Used" -Value $Site .StorageUsageCurrent $Result | add-member -membertype NoteProperty -name "Warning Level" -Value $site .StorageQuotaWarningLevel $ResultSet += $Result } #Export Result to csv file $ResultSet | Export-Csv $ReportOutput -notypeinformation Write-Host "Site Quota Report Generated Successfully!" -f Green |
Using PowerShell-CSOM to get Storage details of a Site Collection:
Other than SharePoint Online Management Shell, You can also use CSOM way as an alternate to retrieve storage size metrics of a site collection.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| #Load SharePoint CSOM Assemblies Add -Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add -Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" $SiteURL = "https://crescent.sharepoint.com/" #Get Credentials to connect $Cred = Get-Credential $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials( $Cred .Username, $Cred .Password) #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext( $SiteURL ) $Ctx .Credentials = $Credentials $Site = $Ctx .Site $Ctx .Load( $Site ) #Get Storage Details $Site .Retrieve( "Usage" ) $Ctx .ExecuteQuery() $Site .Usage.Storage |
#Read more: http://www.sharepointdiary.com/2017/04/sharepoint-online-get-storage-size-quota-report-using-powershell.html#ixzz5Pf0sRNH5
No comments:
Post a Comment