How to get data for 3 sites only using "Get-PnPTenantSite" PowerShell command?

Yuvraj Patil 441 Reputation points
2024-08-23T12:46:28.68+00:00

Hello,

I want to get data for just 3 sites using "Get-PnPTenantSite" PowerShell command. I dont want to get all data and then filter for just 3 sites or using Where-Object for filtering, because its like getting all data will take a lot of time. Is there a way we can pass a filter and get data filtered from SPO server only?

"Filter" is there for "Get-PnPTenantSite" command but dont know how to use "in". Able to use "like" or "eq", "like" may match with other sites as well which I dont want and "eq" will work with only single site url. Is there any "OR" we can use so we can have "eq" site 1 OR "eq" site 2 OR "eq" site 3 ?

Thanks in advance!

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.
3,030 questions
{count} votes

Accepted answer
  1. Xyza Xue_MSFT 25,466 Reputation points Microsoft Vendor
    2024-08-26T07:14:53.12+00:00

    Hi @Yuvraj Patil ,

    Using the following powershell code:

    #Parameters
    $AdminCenterURL = "https://yourdomain-admin.sharepoint.com"  
    #Connect to Admin Center
    Connect-PnPOnline -Url $AdminCenterURL -Interactive
     
    #Get the Site's detailed info
    Get-PnPTenantSite | where {$_.Url -eq "https://yourdomain.sharepoint.com/sites/xyza1"  -or  $_.Url -eq "https://yourdomain.sharepoint.com/sites/xyzax"  -or  $_.Url -eq "https://yourdomain.sharepoint.com/sites/0718"}
    
    

    Result:User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.