pnp / pnpcore

The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working with SharePoint Online and Teams which is agnostic to the underlying API's being called
https://aka.ms/pnp/coresdk/docs
MIT License
288 stars 188 forks source link

URL Filter option for all tenant sites #1474

Closed raclettierer closed 1 month ago

raclettierer commented 1 month ago

Category

Describe the feature

I like to query only a subset of all tenant sites. With PNP Powershell I can set a query based on url.

Describe the solution you'd like

I need to set a filter for the url in code ... await adminContext.GetSiteCollectionManager().GetSiteCollectionsAsync(filter: SiteCollectionFilter.ExcludePersonalSites)

Similar like Get-PnPTenantSite -Filter "Url -like '/sites/myprefix_'" -Detailed or Get-SPOSite -Filter { Url -like "contoso.sharepoint.com/sites/18" }

Additional context

jansenbe commented 1 month ago

Hey @raclettierer ,

In PnP Core SDK under the covers we use three different approaches to enumerate site collections depending on the permissions used when issuing the request. See https://github.com/pnp/pnpcore/blob/dev/src/sdk/PnP.Core.Admin/Model/SharePoint/Core/Internal/SiteCollectionEnumerator.cs#L18-L35. In PowerShell a specific CSOM method is used for this reason (https://github.com/pnp/powershell/blob/bdd6d09cd16c08915e92df5f8ab48acf0d2af9ff/src/Commands/Admin/GetTenantSite.cs#L74-L114).

Given our current implementation this is not something we can easily add right now. I would recommend the following strategies:

jansenbe commented 1 month ago

Hi @raclettierer ,

I'll be closing this one as we do not want to pull in more CSOM that necessary, hope the provided strategies do help.