question

OleksiiKolinko-2004 avatar image
0 Votes"
OleksiiKolinko-2004 asked EmilyDu-MSFT commented

Retrieve programmatically SharePoint Online storage space

How can I retrieve programmatically SharePoint Online allocated (purchased) storage space of the whole tenant, which is visualized "In the upper right of the page":
https://docs.microsoft.com/en-us/sharepoint/manage-site-collection-storage-limits

In report below, it is possible to retrieve used storage space, but not the allocated.

https://docs.microsoft.com/en-us/graph/api/reportroot-getsharepointsiteusagestorage?view=graph-rest-beta

dotnet-csharpoffice-sharepoint-online
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@OleksiiKolinko-2004
Thanks for sharing your solution.

You could accept your solution as answer.


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




0 Votes 0 ·
MartinDay avatar image
0 Votes"
MartinDay answered

Hi

You can use Get-SPOTenant which will return a property called StorageQuota.

Docs article here.

Hope this helps!

Martin


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

EmilyDu-MSFT avatar image
0 Votes"
EmilyDu-MSFT answered

Try below PowerShell.

 #Config Parameters
 $AdminSiteURL="https://testLZ-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

Reference:
https://www.sharepointdiary.com/2017/04/sharepoint-online-get-storage-size-quota-report-using-powershell.html


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OleksiiKolinko-2004 avatar image
0 Votes"
OleksiiKolinko-2004 answered EmilyDu-MSFT commented
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@OleksiiKolinko-2004
Congratulations on solving this issue and thanks for sharing your solution.

Please remember to accept your solution as answer.

It will do great help to those who meet the similar question in this forum.

Thanks again for your contribution.


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




0 Votes 0 ·