SharePoint Application Information PowerShell Scripts

In this article we can explore the procedure necessary to generate SharePoint application information.

What is Application Information?

The Application Information consists of the following components:

  1. Web Application
  2. Site Collection
  3. Site
  4. List
  5. Item

Note 

You need to have PowerShell execution experience to use these scripts.

Scripts

The following is the PowerShell script to get all web applications.

# Get Web Applications

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
foreach ($websvc in $websvcs)
{
    foreach ($webapp in $websvc.WebApplications)
    {
        echo $webapp.Name
    }
}

The following is the PowerShell script to get all Site Collections.

# Get Site Collections

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
foreach ($websvc in $websvcs)
{
    foreach ($webapp in $websvc.WebApplications)
    {
         foreach ($site in $webapp.Sites)
         {
            echo $site.HostName $site.Url $site.LastContentModifiedDate $site.ContentDatabase.Name $site.WebApplication.Name
         }        
    }
}

The following is the PowerShell script to get all sites.

# Get Sites

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
foreach ($websvc in $websvcs)
{
    foreach ($webapp in $websvc.WebApplications)
    {
         foreach ($site in $webapp.Sites)
         {
             foreach ($web in $site.AllWebs)
             {
                 echo $web.Title $web.Url $web.Created $web.LastItemModifiedDate $web.WebTemplate $web.Site.Url
             }
         }        
    }
}

The following is the PowerShell script to get all lists.

# Get Lists

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
foreach ($websvc in $websvcs)
{
    foreach ($webapp in $websvc.WebApplications)
    {
         foreach ($site in $webapp.Sites)
         {
             foreach ($web in $site.AllWebs)
             {
                 foreach ($list in $web.Lists)
                 {
                     echo $list.Title $list.DefaultViewUrl $list.Created $list.LastItemModifiedDate $list.ItemCount $list.IsApplicationList $list.ParentWeb.Url
                 }
             }
         }        
    }
}

The following is the PowerShell script to get all items.

# Get Items

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
foreach ($websvc in $websvcs)
{
    foreach ($webapp in $websvc.WebApplications)
    {
         foreach ($site in $webapp.Sites)
         {
             foreach ($web in $site.AllWebs)
             {
                 foreach ($list in $web.Lists)
                 {
                    foreach ($item in $list.Items)
                    {
                         echo $item.DisplayName
                     }
                  }
             }
         }        
    }
}

HTML Report

I have consolidated all the scripts to generate an HTML file.  Please see the attachments section to download it.

On running the script, an HTML file will be generated in the same directory, that would look as in the following.

HTML Report
 
Site Collection 
 
Sites 
Lists 

Summary

In this article we have explored the SharePoint Application Information PowerShell scripts. I hope this will be useful in real-world scenarios. Please find the source code attached.

The same functionality has been integrated into the Documentation add-in of Squadron (Free Tool).