Dec 08 2020 07:30 PM
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
$ODFBSites = Get-PnPTenantSite -IncludeOneDriveSites -Filter "Url -like '-my.sharepoint.com/personal/ -and Url -like domainname'"| Select-Object Owner, Title, URL, StorageQuota, StorageUsageCurrent | Sort-Object StorageUsageCurrent -Desc
$TotalODFBGBUsed = [Math]::Round(($ODFBSites.StorageUsageCurrent | Measure-Object -Sum).Sum /1024,2)
$Report = @()
ForEach ($Site in $ODFBSites) {
$ReportLine = [PSCustomObject][Ordered]@{
Owner = $Site.Title
Email = $Site.Owner
URL = $Site.URL
QuotaGB = [Math]::Round($Site.StorageQuota/1024,2)
UsedGB = [Math]::Round($Site.StorageUsageCurrent/1024,4) }
$Report += $ReportLine }
$Report | Export-CSV -NoTypeInformation c:\somepathtoadrive
Any ideas what i'm missing or is not possible using PnP?
Thanks in Advance
Dec 09 2020 03:34 PM
Hello @Patrick Rote,
Did you try -Detailed ?
By default, not all returned attributes are populated.
Reference: Get-PnPTenantSite Documentation
Hope that helps.
Dec 10 2020 07:55 AM
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.