Get all site collection of a web application using powershell in SharePoint 2019

Andy 1,346 Reputation points
2022-09-22T03:32:53.237+00:00

I want to get all collection url and name of a web application and export the values into excel, how to do that?

SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,794 questions
Excel Management
Excel Management
Excel: A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.Management: The act or process of organizing, handling, directing or controlling something.
1,638 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yi Lu_MSFT 17,456 Reputation points
    2022-09-22T06:49:21.057+00:00

    Hi @Andy
    You could use the following powershell:

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue  
       
    #Web application URL and CSV File location Variables  
    $WebAppURL="https://intranet.crescent.com"  
    $CSVFile="C:\SitesList.csv"  
       
    #Get list of site collections in a web application powershell  
    Get-SPWebApplication $WebAppURL | Get-SPSite -Limit All | ForEach-Object {  
        New-Object -TypeName PSObject -Property @{  
                 SiteName = $_.RootWeb.Title  
                 Url = $_.Url  
                 DatabaseName = $_.ContentDatabase.Name }  
    } | Export-CSV $CSVFile -NoTypeInformation  
    

    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][2] to enable e-mail notifications if you want to receive the related email notification for this thread. [2]: https://learn.microsoft.com/en-us/answers/support/email-notifications


0 additional answers

Sort by: Most helpful