Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 13 additions & 25 deletions src/Commands/UserProfiles/GetUserOneDriveQuota.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<SiteProperties>();
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}");
}
}
}
Expand Down
Loading