SharePoint 2016: Simple OOTB Farm Inventory Methods
![]() |
This topic is work in progress. Please abstain from editing it right now. You're welcome to contribute here when its done! |
Introduction
The following are simple methods that can be used to inventory a SharePoint farm.
Inventory Methods
All Farm Sites (aka "webs")
This method pulls all webs in all site collections in all web applications, except for MySites, and then stores the results in a CSV file. An example is also provided on how to implement filtering and sorting.
Get-SPWebApplication | Get-SPSite -Limit "All" | Where-Object {$_.URL -NotLike "*MySites*"} | Get-SPWeb -Limit "All" | Sort-Object url | Export-CSV -Path "D:\Temp\AllFarmWebs.csv"
All Farm Site Collections
This method pulls all site collections in all web applications, except for MySites, and then stores the results in a CSV file. This example also shows how to select just the properties that you want.
Get-SPWebApplication | Get-SPSite -Limit "All" | Where-Object {$_.URL -NotLike "*MySites*"} | Select-Object HostName,URL,{$_.Usage.Storage/1GB} | Sort-Object url | Export-CSV -Path "D:\Temp\AllFarmWebs.csv"
All Sites in a Site Collection
This method inventories all sites (aka "webs") in a given site collection:
$site = Get-SPSite "https://contoso.com";$site.AllWebs | Export-csv -path "D:\temp\AllSiteCollectionWebs.csv"
All Farm Web Applications
This is similar to the previous one but leaving off the Get-SPSite method and filtering.
Get-SPWebApplication | Select URL, DisplayName, Name, ID, Status, Version| Sort DisplayName | Export-CSV -Path "D:\Temp\Get-SPWebApplication.csv"
All Farm Content Databases
This method inventories all farm content databases and some of their properties, such as size and number of site collections:
Get-SPContentDatabase | Select -Property Name,ID,WebApplication, @{e={$_.CurrentSiteCount};l='Sites'}, @{e={($_.DiskSizeRequired/1GB).ToString("0.##")};l='Size(GB)'} | Export-CSV -Path "D:\Temp\Get-SPContentDatabase.csv"
All Farm Solutions
This method inventories all of the solutions deployed to the farm:
Get-SPSolution | Export-csv -path "D:\temp\Get-SPSolution.Farm.csv"
All Farm Features
This method inventories all of the activated OOTB Microsoft and deployed features having farm scope:
Get-SPFeature | Where {$_.Scope -eq "Farm"} | Export-csv -path "D:\temp\Get-SPFeature.Farm.csv"
All Web Application Features
This method inventories all of the activated features for a specific web application having web application scope:
Get-SPFeature -WebApplication "https://contoso.com/" | Export-csv -path "D:\temp\Get-SPFeature.WebApp.csv"
All Site Collection Features
This method inventories all activated features in a site collection:
Get-SPFeature -Site "https://contoso.com" | Export-csv -path "D:\temp\Get-SPFeature.Site.csv"
All Features in all Sites ("Webs") in a Site Collection
This method inventories all features for all sites in a site collection::
Get-SPSite -Identity "https://contoso.com" | Get-SPWeb -Limit ALL |%{ Get-SPFeature -Web $_ } | Export-csv -path "D:\temp\Get-SPFeature.Web.csv"
All Lists and Document Libraries in Site Collection
This method retrieves all lists and document libraries in a site collection
function Get-SPSiteInventory {
Param(
[string]$Url,
[string]$path
)
#
# To run it from the prompt, first dot-source it like so:
# ". C:\MyDir\Get-SPSiteInventory.ps1"
# then execute it like any other function.
#
Start-SPAssignment -Global
$site = Get-SPSite $Url
$allWebs = $site.allwebs
Add-Content -Path $path -Value "ParentWebUrl, DefaultViewUrl,Title, BaseType, BaseTemplate, Author, Created, LastModifiedDate, ID, EventReceivers, Count"
foreach ($spweb in $allWebs) {
$allLists = $spweb.Lists
foreach ($splist in $allLists){
$str = $splist.ParentWebUrl + ", " + $splist.DefaultViewUrl + ", " + $splist.Title + ", " + $splist.BaseType + ", " + $splist.BaseTemplate + ", " + $splist.Author + ", " + $splist.Created + ", " + $splist.LastModifiedDate + ", " + $splist.ID + ", " + $splist.EventReceivers + "," + $splist.items.count
Add-Content -Path $path -Value $str
}
$spweb.dispose()
}
$site.dispose()
Stop-SPAssignment -Global
}
tbd
tbd
tbd
tbd
tbd
tbd
tbd
tbd
tbd
tbd
tbd
tbd
tbd
References
Notes
- tbd