I wanted to get an idea of how many people were using discussion boards in my SharePoint Server environment and in what sites. I modified a script I found to create the sort of inventory list I needed and ended with a script that:
- Provides a list within PowerShell of each URL, site name, and list name found matching a specific list type.
- Provides a total count and save location confirmation at the end.
- Exports a CSV file of the details to a specified location.
Find the Template ID for the list you’re searching for
List template ID options are as follows, taken from this Docs article. You’ll need the Template ID of the type of list you wish to search in your SharePoint environment.
List template type | Template ID | Base type | Description |
---|---|---|---|
Custom List | 100 | 0 | A basic list that can be adapted for multiple purposes. |
Document Library | 101 | 1 | Contains a list of documents and other files. |
Survey | 102 | 4 | Fields (2) on a survey list represent questions that are asked of survey participants. Items in a list represent a set of responses to a survey. |
Links | 103 | 0 | Contains a list of hyperlinks and their descriptions. |
Announcements | 104 | 0 | Contains a set of simple announcements. |
Contacts | 105 | 0 | Contains a list of contacts used for tracking people in a site (2). |
Calendar | 106 | 0 | Contains a list of single and recurring events. An events list has special views for displaying events on a calendar. |
Tasks | 107 | 0 | Contains a list of items that represent finished and pending work items. |
Discussion Board | 108 | 0 | Contains discussions entries and their replies. |
Picture Library | 109 | 1 | Contains a library adapted for storing and viewing digital pictures. |
DataSources | 110 | 1 | Contains data connection description files. |
Form Library | 115 | 1 | Contains XML documents. An XML form library can also contain templates for displaying and editing XML files through forms, as well as rules for specifying how XML data is converted to and from list items. |
No Code Workflows | 117 | 1 | Contains additional workflow definitions that describe new processes that can be used in lists. These workflow definitions do not contain advanced code-based extensions. |
Custom Workflow Process | 118 | 0 | Contains a list used to support custom workflow process actions. |
Wiki Page Library | 119 | 1 | Contains a set of editable Web pages. |
CustomGrid | 120 | 0 | Contains a set of list items with a grid-editing view. |
No Code Public Workflows | 122 | 1 | A gallery for storing workflow definitions that do not contain advanced code-based extensions. |
Workflow History | 140 | 0 | Contains a set of history items for instances of workflows. |
Project Tasks | 150 | 0 | Contains a list of tasks with specialized views of task data in the form of Gantt chart. |
Public Workflows External List | 600 | 0 | An external list for viewing the data of an external content type. |
Issues Tracking | 1100 | 5 | Contains a list of items to track issues. |
Modify the PowerShell script to suit your needs
Once you have the list template ID you wish to query from the table above, modify the PowerShell script found below as follows:
- Replace the $ListTemplateId variable value with your desired template ID.
- Replace the -WebApplication parameter’s URL value with your own SharePoint web app address.
- Replace the $saveCSVLocation value inside the double-quotes with the path to where you’d like the export to be written.
Get all SharePoint list types in one report
Want it all? You could modify the script by replacing -eq $ListTemplateId on line 15 with -gt 0. Then replace line 21 with:
@{Site=$web.Title;ListName=$list.Title;Type=$list.BaseTemplate;URL=($web.Url + "/" + $i.DefaultView.Url)}) | % { New-Object object | Add-Member -NotePropertyMembers $_ -PassThru }
And replace line 25 with:
write-Output ($web.Title + "," + $list.Title + "," + $list.BaseTemplate + "," + $web.Url + "/" + $i.DefaultView.Url) | Out-File $SaveLocationFinal -Append
Now your report will include all list types, and an added column to specify that list type. Note that this will take a while to run in larger environments.
You could also modify the script to only display in PowerShell (delete lines 23-25 and 31-33) or only export to CSV (delete lines 19-22 and 31-33) but I wanted both outputs for my purposes.
Idea: Take it further with Power BI
Take this to the next level by automating the PowerShell script to run on a schedule exporting results to a folder Power BI reads on an automatic refresh. This is an easy way to get a hands-off dashboard of SharePoint usage by list type.