From d8614dd79c0249a959629bbd4300eac90db1bf95 Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Tue, 28 Apr 2026 22:45:28 +0300 Subject: [PATCH 1/2] Fix Get-PnPUserOneDriveQuota hanging issue by retrieving resolved OneDrive site directly --- CHANGELOG.md | 1 + .../UserProfiles/GetUserOneDriveQuota.cs | 36 +++++++------------ 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f452dc829..c290fa02f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added parameter IncreaseRequestTimeout to `Get-PnPSearchCrawlLog` cmdlet. [#5223](https://github.com/pnp/powershell/pull/5223) ### Fixed +- Fix `Get-PnPUserOneDriveQuota` hanging in some tenants by retrieving the resolved OneDrive site directly instead of using a filtered tenant site query. [#4543](https://github.com/pnp/powershell/issues/4543) - Fix `Get-PnPEntraIDUser` to align supported Graph permission metadata, preserve `-Select` for GUID-based identity lookups, and expose `-UseBeta` consistently across parameter sets. [#5290](https://github.com/pnp/powershell/pull/5290) - Fix `Set-PnPView -Aggregations` parameter not showing aggregations in SharePoint online. [#4868](https://github.com/pnp/powershell/pull/4868) - Fix `-CreateDrive` parameter not working correctly in `Connect-PnPOnline`. [#4869](https://github.com/pnp/powershell/pull/4869) diff --git a/src/Commands/UserProfiles/GetUserOneDriveQuota.cs b/src/Commands/UserProfiles/GetUserOneDriveQuota.cs index d65d4aa19..9cff9d0d0 100644 --- a/src/Commands/UserProfiles/GetUserOneDriveQuota.cs +++ b/src/Commands/UserProfiles/GetUserOneDriveQuota.cs @@ -1,7 +1,5 @@ -using System.Collections.Generic; -using System.Linq; +using System; using System.Management.Automation; -using Microsoft.Online.SharePoint.TenantAdministration; using Microsoft.SharePoint.Client; using Microsoft.SharePoint.Client.UserProfiles; @@ -28,32 +26,22 @@ protected override void ExecuteCmdlet() AdminContext.Load(properties); AdminContext.ExecuteQueryRetry(); - var personalSiteUrl = properties.PersonalUrl; - - SPOSitePropertiesEnumerableFilter filter = new SPOSitePropertiesEnumerableFilter() - { - IncludePersonalSite = PersonalSiteFilter.Include, - IncludeDetail = true, - Template = "SPSPERS", - Filter = $"Url -eq '{personalSiteUrl.TrimEnd('/')}'" - }; - - var sitesList = Tenant.GetSitePropertiesFromSharePointByFilters(filter); - var sites = new List(); - do + var personalSiteUrl = properties.PersonalUrl?.TrimEnd('/'); + if (string.IsNullOrWhiteSpace(personalSiteUrl)) { - Tenant.Context.Load(sitesList); - Tenant.Context.ExecuteQueryRetry(); - sites.AddRange(sitesList.ToList()); - } while (!string.IsNullOrWhiteSpace(sitesList.NextStartIndexFromSharePoint)); - - var userSite = sitesList.Where(s => s.Url.ToLower() == personalSiteUrl.TrimEnd('/').ToLower()).FirstOrDefault(); + LogWarning($"Couldn't find onedrive quota for the account: {Account} "); + return; + } - if (userSite != null) + try { + var userSite = Tenant.GetSitePropertiesByUrl(personalSiteUrl, true); + AdminContext.Load(userSite); + AdminContext.ExecuteQueryRetry(); + WriteObject(userSite.StorageMaximumLevel * 1024 * 1024); } - else + catch (ServerException e) when (string.Equals(e.ServerErrorTypeName, "Microsoft.Online.SharePoint.Common.SpoNoSiteException", StringComparison.InvariantCultureIgnoreCase)) { LogWarning($"Couldn't find onedrive quota for the account: {Account} "); } From e7a1622d7916fd946ecbca93cc5981afcd56145c Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Tue, 28 Apr 2026 22:55:07 +0300 Subject: [PATCH 2/2] Fix OneDrive quota logging message for consistency and clarity Co-authored-by: Copilot --- CHANGELOG.md | 2 +- src/Commands/UserProfiles/GetUserOneDriveQuota.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c290fa02f..c0da1cb8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,7 +59,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added parameter IncreaseRequestTimeout to `Get-PnPSearchCrawlLog` cmdlet. [#5223](https://github.com/pnp/powershell/pull/5223) ### Fixed -- Fix `Get-PnPUserOneDriveQuota` hanging in some tenants by retrieving the resolved OneDrive site directly instead of using a filtered tenant site query. [#4543](https://github.com/pnp/powershell/issues/4543) +- Fix `Get-PnPUserOneDriveQuota` hanging in some tenants by retrieving the resolved OneDrive site directly instead of using a filtered tenant site query. [#5306](https://github.com/pnp/powershell/pull/5306) - Fix `Get-PnPEntraIDUser` to align supported Graph permission metadata, preserve `-Select` for GUID-based identity lookups, and expose `-UseBeta` consistently across parameter sets. [#5290](https://github.com/pnp/powershell/pull/5290) - Fix `Set-PnPView -Aggregations` parameter not showing aggregations in SharePoint online. [#4868](https://github.com/pnp/powershell/pull/4868) - Fix `-CreateDrive` parameter not working correctly in `Connect-PnPOnline`. [#4869](https://github.com/pnp/powershell/pull/4869) diff --git a/src/Commands/UserProfiles/GetUserOneDriveQuota.cs b/src/Commands/UserProfiles/GetUserOneDriveQuota.cs index 9cff9d0d0..9b750eb76 100644 --- a/src/Commands/UserProfiles/GetUserOneDriveQuota.cs +++ b/src/Commands/UserProfiles/GetUserOneDriveQuota.cs @@ -29,7 +29,7 @@ protected override void ExecuteCmdlet() var personalSiteUrl = properties.PersonalUrl?.TrimEnd('/'); if (string.IsNullOrWhiteSpace(personalSiteUrl)) { - LogWarning($"Couldn't find onedrive quota for the account: {Account} "); + LogWarning($"Couldn't find OneDrive quota for the account: {Account}"); return; } @@ -43,7 +43,7 @@ protected override void ExecuteCmdlet() } catch (ServerException e) when (string.Equals(e.ServerErrorTypeName, "Microsoft.Online.SharePoint.Common.SpoNoSiteException", StringComparison.InvariantCultureIgnoreCase)) { - LogWarning($"Couldn't find onedrive quota for the account: {Account} "); + LogWarning($"Couldn't find OneDrive quota for the account: {Account}"); } } }