Get All Site Collections in a Web Applications using PowerShell
How to get all site collections of a web application in SharePoint?
To get all site collections in web application, from SharePoint central Admin, follow these steps:
Here is the PowerShell to list all site collections in web application.
While the above code written in classic manner, you can use PowerShell one-liner to get list of all site collections in web application:
PowerShell to get all site collections in a web application:
This time, lets use PowerShell expressions to dig into site collection properties, say: Site Name, content database, etc.
How to get all site collections in a web application and Export to CSV
How about get all site collections in a web application using PowerShell and Export to CSV?
To get all site collections in web application, from SharePoint central Admin, follow these steps:
- Go to SharePoint Central Admin Site >> Application Management
- Click on "View all site collections" link under Site Collections Group. Select your web application. This page lists all site collections in the selected web application.
Here is the PowerShell to list all site collections in web application.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Set the Web application URL $WebAppURL="http://intranet.crescent.com" #Get the Web Application $WebApp = Get-SPWebApplication $WebAppURL #Get all Site collections from the web application $SitesCollection = $WebApp.Sites #Enumerate all site collections in the web application Foreach($Site in $SitesCollection) { #Get Site Collection URL, Owner, Content Database Details Write-host $Site.URL }
While the above code written in classic manner, you can use PowerShell one-liner to get list of all site collections in web application:
Get-SPWebApplication "http://intranet.crescent.com" | Get-SPSite | Select URL
PowerShell to get all site collections in a web application:
This time, lets use PowerShell expressions to dig into site collection properties, say: Site Name, content database, etc.
Get-SPWebApplication "http://intranet.crescent.com" | Get-SPSite -Limit All | Select URL,@{Name="Site Name"; Expression={$_.RootWeb.Title}},Owner
How to get all site collections in a web application and Export to CSV
How about get all site collections in a web application using PowerShell and Export to CSV?
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Web application URL and CSV File location Variables $WebAppURL="http://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 -NoTypeInformationThis Script gets all site collections from the given web application and exports the site collection data to CSV

Hi, how can you add the Administrators to the report?
ReplyDeleteYes, $Site.RootWeb.SiteAdministrators will do!
DeleteSmall correction, Need to put "-Limit ALL" for exporting all the record.
ReplyDeleteFixed it! Yes, by default it returns only 200 site collections!
DeleteCan you give me a script by which I can the list of all the site collections and sites under a web application and it's owners names as well? Needed urgently.
ReplyDeleteHere you go: PowerShell to Get All SharePoint Site Collection Owners in SharePoint
Delete