Forum Discussion

soniabouna's avatar
soniabouna
Copper Contributor
Feb 16, 2024

Allow filtering on site properties

It would be great to be able to filter the list sites request on site properties like "isPersonalSite" or "deleted".

Currently, one can only filter on "siteCollection".

1 Reply

  • MikeCrowley's avatar
    MikeCrowley
    Iron Contributor

    soniabouna You Can filter out personal sites with the ne clause. For example, in PowerShell:

     

    $uri = @'
    beta/sites/getAllSites?$filter=isPersonalSite ne true&top=999&$count=true
    '@
    $headers =@{
        ConsistencyLevel = "eventual"
    }
    $Sites = Invoke-MgGraphRequest -Uri $uri -Headers $headers
    $Sites.value

Resources