Forum Discussion
Patrick Rote
Dec 09, 2020Iron Contributor
How can i get a list of OneDrive for Business sites in the tenant - showing storage etc using PnP
Hi there, I want to be able to list all onedrive url and also their storage and current usage using PnP Powershell. I ran the script below but the storagequote and current usage was blank $OD...
Patrick Rote
Dec 10, 2020Iron Contributor
AndySvints Thanks but it doesn't get the Storage 😞
AndySvints
Dec 10, 2020Steel Contributor
I think you are selecting wrong properties...
QuotaGB should be StorageMaximumLevel and UsedGB should be StorageUsage.
So your code will look something like this:
$ODFBSites = Get-PnPTenantSite -IncludeOneDriveSites -Filter "Url -like '-my.sharepoint.com/personal'"
$Report = @()
ForEach ($Site in $ODFBSites) {
$ReportLine = [PSCustomObject][Ordered]@{
Owner = $Site.Title
Email = $Site.Owner
URL = $Site.URL
QuotaGB = [Math]::Round($Site.StorageMaximumLevel/1024,2)
UsedGB = [Math]::Round($Site.StorageUsage/1024,4) }
$Report += $ReportLine }
Hope that helps.