Skip to content

fix: SiteScope All enumeration pollution + DryRun would-apply outcome - #27

Merged
luigilink merged 3 commits into
mainfrom
fix/scope-all-pollution-and-dryrun
Jul 15, 2026
Merged

fix: SiteScope All enumeration pollution + DryRun would-apply outcome#27
luigilink merged 3 commits into
mainfrom
fix/scope-all-pollution-and-dryrun

Conversation

@luigilink

Copy link
Copy Markdown
Owner

Closes #26

Two bugs found during live Azure Automation runbook testing.

Bug 1 — Enumeration pollution (SiteScope: All)

Get-TenantSiteUrls emitted status via Write-Output, which PowerShell captured into the returned array. The status strings were then processed as sites and failed:

Processing Site: Connecting to tenant admin center: https://...-admin... ...  -> Invalid URI
Processing Site: Discovered 9 site collection(s) from the tenant.            -> Invalid URI

Fix: informational messages use Write-Verbose; the function returns only the URL array (return ,[string[]]$urls); the caller logs the discovered/processed count.

Bug 2 — DryRun reported 'Applied'

In DryRun the site version policy path recorded Applied even though ShouldProcess/-WhatIf blocked the change. Fix: record a WouldApply outcome and log 'would apply'; the report card ('Would apply') and run summary ('N would apply') reflect the simulation.

Bonus (confirmed app-only behaviour)

Live testing showed Get-PnPTenantSite and Get-PnPSiteVersionPolicy reads work with a Managed Identity (SiteScope: All + InheritFromTenant enumerated 9 sites, all 'no drift'). The wiki app-only note is softened accordingly.

Testing

Invoke-Pester -> 116 passed, 0 failed. Enumeration purity and DryRun would-apply verified functionally. Version bumped to 3.1.3.

Two bugs found during live runbook testing of SiteScope: All:

1. Get-TenantSiteUrls emitted informational text via Write-Output, which
   PowerShell captured into the returned array, so status strings were
   processed as bogus site URLs ('Invalid URI'). Use Write-Verbose inside
   the function and return only the URL array (return ,[string[]]); the
   caller logs the discovered/processed count.
2. In DryRun the site version policy path recorded Outcome='Applied' even
   though ShouldProcess prevented the change. Record 'WouldApply' and log
   'would apply' in DryRun; the report card and summary reflect it.

Bump to 3.1.3.

Refs #26
Note the SiteScope: All enumeration fix and the DryRun would-apply outcome
in CHANGELOG/RELEASE-NOTES, and soften the Configuration app-only note now
that live testing confirmed Get-PnPTenantSite and Get-PnPSiteVersionPolicy
reads work with a Managed Identity.

Refs #26
@luigilink
luigilink merged commit a4b26d9 into main Jul 15, 2026
1 check passed
@luigilink
luigilink deleted the fix/scope-all-pollution-and-dryrun branch July 15, 2026 13:11
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.

SiteScope All: enumeration pollutes site list; DryRun reports 'Applied' instead of simulated

1 participant