I need to find a set of SharePoint sites to process with PowerShell, but the Graph site APIs don't seem to offer much filtering. Is there a practical workaround?
How do you find SharePoint sites when Graph filtering falls short?
Answers
Use another Microsoft 365 cmdlet to find objects associated with the sites you want, then use those results as an intermediate step to retrieve or process the sites. That moves the selection work out of the Graph site query when its filters aren't enough.
The exact cmdlet and matching step depend on which associated objects you can use to identify the sites. Check that the relationship gives you the set you actually need before running changes against them.
Reply to this answer
Another option is to call the Graph API directly rather than going through the PowerShell SDK. That won't add filtering the API doesn't support, but it can make the request easier to work with than a long generated cmdlet name.
The SDK names are generated from Graph metadata, and the help for some commands can be pretty thin. If a cmdlet is hard to decipher, looking at the underlying API operation may be more useful.
Reply to this answer
Add your answer
Answers are reviewed before publication.
p.726~claspfaucet:
Good distinction. Switching to direct API calls changes the interface, not the filtering capabilities of the endpoint.