Monday, January 11, 2016

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 site in IIS. 

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 all web applications sharepoint powershell
The above PowerShell cmdlet gives DisplayName, Url of all SharePoint web applications.To get a specific web application, use:
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)
#Or a one liner to loop through web applications
#Get-SPWebApplication | Select URL

Get all web application details in SharePoint using PowerShell
Lets audit all web applications in SharePoint with additional details such as 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

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...