-2

How to get all Web Applications with Content DB names from SharePoint 2013/2016 Farm using PowerShell CSOM?

Pradeep Kolli
  • 33
  • 1
  • 5

1 Answers1

0

simple one:

#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


#Read more: https://www.sharepointdiary.com/2016/01/get-all-web-applications-in-sharepoint-using-powershell.html#ixzz7JoRyZrx8

with more data:

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


#Read more: https://www.sharepointdiary.com/2016/01/get-all-web-applications-in-sharepoint-using-powershell.html#ixzz7JoSCM4YG

more info - https://www.sharepointdiary.com/2016/01/get-all-web-applications-in-sharepoint-using-powershell.html

Tal Folkman
  • 2,368
  • 1
  • 7
  • 21