Get All Web Applications in SharePoint using PowerShell

Web Applications are the top-level containers in SharePoint. Each Web Application we create in SharePoint central administration is associated with the site in IIS.

How to get all web applications in SharePoint farm?

In many SharePoint environments, there are separate web applications for different functions. For example, one web application might be used for the public-facing website, while another is used for the intranet. There may also be other web applications for different departments or teams. If you want to get all of these web applications from the SharePoint farm, PowerShell can help. This blog post will show you how to use PowerShell to get all web applications in SharePoint.

To get a list of all available web applications in SharePoint, navigate to:

  • SharePoint 2016 Central Administration >> Application Management 
  • Manage Web Application Link.
    how to get all web applications sharepoint using powershell

How to get all web applications SharePoint using PowerShell?

Get-SPWebApplication cmdlet retrieves all the Web Applications in the Current farm.

Get-SPWebApplication
get all web applications sharepoint powershell

The above PowerShell cmdlet gives DisplayName, Url of all SharePoint web applications. To get a specific web application, use:

Get-SPWebApplication https://yourwebappURL.com

You can iterate through web applications in PowerShell, as:

#Get all web applications sharepoint using powershell
$WebAppColl = Get-SPWebApplication

#Iterate through each web application
Foreach ($WebApp in $WebAppColl)
{
    $Webapp.Url
}
#Or a one liner to loop through web applications
#Get-SPWebApplication | Select URL

This will work on both SharePoint 2013 and 2016 environments. The script requires that you have Farm Administrator rights to run it.

Get all web application details in SharePoint using PowerShell

Let’s audit all web applications in SharePoint with additional details such as the number of content databases, authentication type, application pool name, etc. and generate a report:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Parameters
$ReportOutput= "C:\WebApplications-Report.csv"
$DataCollection = @()

#Get all web applications sharepoint using powershell
$WebAppColl = Get-SPWebApplication
Foreach ($WebApp in $WebAppColl)
{
    #Determine the Authentication Type of the web application
    if ($WebApp.UseClaimsAuthentication) { $AuthticationTYpe = "Claims"} else {$AuthticationTYpe = "Classic" }

    #Get All Managed Paths of the web application
    $ManagedPaths =(Get-SPManagedPath -WebApplication $WebApp | Select -ExpandProperty Name) -join ","

    $WebAppData = new-object PSObject
    $WebAppData | add-member -membertype NoteProperty -name "Web Application Name" -Value $WebApp.Name
    $WebAppData | add-member -membertype NoteProperty -name "URL" -Value $WebApp.URL
    $WebAppData | add-member -membertype NoteProperty -name "No.of Content Databases" -Value $WebApp.ContentDatabases.Count 
    $WebAppData | add-member -membertype NoteProperty -name "Authentication Type" -Value $AuthticationTYpe
    $WebAppData | add-member -membertype NoteProperty -name "Application Pool" -Value $WebApp.ApplicationPool.DisplayName
    $WebAppData | add-member -membertype NoteProperty -name "Outgoing E-mail" -Value $WebApp.OutboundMailServiceInstance[0].Server.Address
    $WebAppData | add-member -membertype NoteProperty -name "Managed Paths" -Value $ManagedPaths

    $DataCollection += $WebAppData
}

#Export Results to a CSV File
$DataCollection | Export-csv $ReportOutput -notypeinformation
Write-Host "Web Application Audit Report has been Generated!" -f Green

This script generates the CSV report:

how to get all web applications sharepoint

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *