pnp / pnp/powershell

[BUG] Get-PnPTenantSite returns incorrect property values when retrieving all sites

Open
#5,472 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
904
Forks
407
Avg merge
9h 16m
Merged PRs (30d)
10

Description

Describe the bug

Get-PnPTenantSite can return different values for OverrideTenantAnonymousLinkExpirationPolicy depending on whether a single site or all tenant sites are queried.

The issue occurs with and without -Detailed.

There may also be other properties affected by the same issue, although I have not yet tested all properties.

To Reproduce

$siteUrl = "https://<tenant>.sharepoint.com/sites/<siteurl>"

$singleSite = Get-PnPTenantSite `
    -Identity $siteUrl `
    -Connection $ConAdmin

$allSites = Get-PnPTenantSite `
    -Connection $ConAdmin

$filteredSite = $allSites |
    Where-Object { $_.Url -eq $siteUrl }

$singleSite.OverrideTenantAnonymousLinkExpirationPolicy
$filteredSite.OverrideTenantAnonymousLinkExpirationPolicy

Result:

True
False

The same behavior occurs when using:

Get-PnPTenantSite -Detailed

for the $allSites query.

The site is the same in both cases.

Expected behavior

The same site should return the same property values regardless of whether it is queried individually or as part of the tenant-wide result.

If a property is not available when retrieving all sites, I would expect it to be $null rather than returning an incorrect/default value such as False.

Actual behavior

The individual query returns:

OverrideTenantAnonymousLinkExpirationPolicy = True

while the tenant-wide query returns:

OverrideTenantAnonymousLinkExpirationPolicy = False

This makes the property unreliable for tenant-wide auditing and raises the possibility that other SPOSite properties may be affected as well.

Environment

  • PnP.PowerShell: 3.4.1
  • SharePoint Online
  • Windows PowerShell

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Get-PnPTenantSite cmdlet implementation and trace the separate single-site and tenant-wide retrieval paths, including how OverrideTenantAnonymousLinkExpirationPolicy is populated. Reproduce the example against SharePoint Online, then add or update regression coverage for both query modes. Done means the same site's property value is preserved, or unavailable values are returned as $null rather than a default.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.