SPO - Powershell - Filtering subsite

Tan Huynh 241 Reputation points
2021-07-05T21:41:47.627+00:00

Hello everyone,

I have many subsites and I would like to target only one using below but it does not seem to work. Is there another way to filter? Thanks.

Get-PnPSubWebs -Recurse | Where-Object ($_.ServerRelativeUrl -contains "/sites/main/site1")

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,537 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,649 questions
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,016 Reputation points
    2021-07-06T01:47:43.003+00:00

    Hi @Tan Huynh ,

    You need to use braces { } instead of Parentheses ( ), like the below.

    Get-PnPSubWebs -Recurse | Where-Object {$_.ServerRelativeUrl -contains "/sites/main/site1"}  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Tan Huynh 241 Reputation points
    2021-07-06T12:51:58.893+00:00

    Thank you Michael, works now. I should have known :)

    0 comments No comments