diff --git a/CHANGELOG.md b/CHANGELOG.md index f452dc829..c0da1cb8c 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. [#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 d65d4aa19..9b750eb76 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,34 +26,24 @@ 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} "); + LogWarning($"Couldn't find OneDrive quota for the account: {Account}"); } } }