Skip to content

fix(sharepoint): normalize site storage usage and quotas - #937

Merged
KelvinTegelaar merged 3 commits into
CyberDrain:devfrom
MartinRain:fix/spo-localized-site-usage
Oct 15, 2026
Merged

KelvinTegelaar merged 3 commits into
CyberDrain:devfrom
MartinRain:fix/spo-localized-site-usage

Conversation

@MartinRain

Copy link
Copy Markdown
Contributor

Summary

Fixes #936.

This PR corrects SharePoint Online site storage metrics returned by SPO.Tenant/RenderAdminListData.

The existing normalization logic can produce missing storage usage values when SharePoint returns localized numeric formats, and significantly inflated quotas when values already expressed in bytes are incorrectly treated as MiB.

Changes

  • Extend ConvertTo-SPOAdminListInt64 to support localized thousands separators, including spaces and non-breaking spaces, and integral values with trailing zero decimals.
  • Prefer the byte-valued StorageQuota. field when available.
  • Apply conservative unit handling when StorageQuota. is unavailable, avoiding incorrect conversions for small quotas.
  • Add Pester regression tests covering actual SharePoint response formats, quota boundaries, invalid values, and fallback behavior.

Examples

Raw SharePoint value Expected result
68 478 349 774 68,478,349,774 bytes
68478349774.0000 68,478,349,774 bytes
524288000.000000 500 MiB
1048576000.00000 1,000 MiB
17716740096.0000 16.5 GiB
27487790694400.0 25 TiB

Previously, a 500 MiB quota could incorrectly be reported as 500 TiB.

Validation

  • Reproduced and validated against actual SharePoint admin responses across multiple independent Microsoft 365 tenants.
  • Broad multi-tenant before-and-after comparison confirmed recovery of all previously missing storage usage values.
  • No new missing storage values or changes to the site population were observed.
  • Verified correct normalization of small and large quotas.
  • Added Pester regression tests for localized values, dotted-field precedence, and fallback scenarios.

Performance and scope

  • No additional Microsoft Graph or SharePoint API requests.
  • No per-site enrichment calls.
  • No changes to caching, scheduling, or frontend behavior.
  • No permanent diagnostic logging.
  • Limited to two backend PowerShell files and one Pester test file.

The fix preserves the existing SharePoint data retrieval flow while improving normalization accuracy.

Related issue: #936

@KelvinTegelaar
KelvinTegelaar merged commit 0c82cb6 into CyberDrain:dev Oct 15, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants