I fount the answer:
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://learn.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.
Microsoft 365 and Office | SharePoint | For business | Windows
Developer technologies | C#
3 answers
Sort by: Most helpful
-
-
Martin Day 151 Reputation points
2021-01-11T09:40:26.4+00:00 Hi
You can use Get-SPOTenant which will return a property called StorageQuota.
Docs article here.
Hope this helps!
Martin
-
Emily Du-MSFT 51,836 Reputation points Microsoft External Staff
2021-01-11T10:04:24.657+00:00 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
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.