Get All SharePoint Site Collections in a Web Application using PowerShell
How to get all site collections of a web application in SharePoint?
All site collections and sites within a web application share the same top-level URL. To get all site collections in a web application from SharePoint central Admin, follow these steps:
- Go to SharePoint Central Admin Site >> Application Management.
- Click on the “View all site collections” link under Site Collections Group. Select your web application. This page lists all site collections in the selected web application.
Get all site collections in web application using PowerShell:
Here is the PowerShell to list all site collections in a web application.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Set the Web application URL
$WebAppURL="https://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 is written traditionally, you can use PowerShell one-liner to get a list of all site collections in a web application:
Get-SPWebApplication "https://intranet.crescent.com" | Get-SPSite | Select URL
PowerShell to get all site collections in a web application:
This time, let’s use PowerShell expressions to dig into site collection properties, say: Site Name, content database, etc.
Get-SPWebApplication "https://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 getting all site collections in a web application using PowerShell and exporting to CSV?
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
This Script gets all site collections from the given web application and exports the data to CSV.
Any way to get last modified for each site?
Can 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.
Here you go: PowerShell to Get All SharePoint Site Collection Owners in SharePoint
Small correction, Need to put “-Limit ALL” for exporting all the record.
Fixed it! Yes, by default it returns only 200 site collections!
Hi, how can you add the Administrators to the report?
Yes, $Site.RootWeb.SiteAdministrators will do!