[BUG] Get-PnPTenantSite returns incorrect property values when retrieving all sites
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
I am seeing the same experience, see my Bug identification #5741 from 2 days ago
Hey @cosibox ,unfortunately this is not something we can fix in PnP. Please raise an issue with MS support.
Once MS fixes it in the backend, it will be available automatically here.
The issue lies with the API response which itself is wrong, you can check the source code here and share with MS support :
https://github.com/pnp/powershell/blob/0fea280d703f9b6d14f3de6572880137b977e6d0/src/Commands/Admin/GetTenantSite.cs#L74-L113