Recently, I had to list find where all of the SharePoint site columns are used in lists across many site collections. I wrote some quick PowerShell to get all SharePoint list columns and write the site collection, list, and column.
Columns: I listed all site columns/list column display names I was seeing if they are used
Sites: all site collections, except my sites
I am sure it can be cleaned up, but it’s quickly to audit the list columns to get a report. I tried to export to CSV but decided it was more time than formatting the few results that came back in the window.
Results: (can be cleaned up easily, but I don’t have time for this quick script)
AuditColumns.ps1
SPSite Url=https://client/sites/docs, Accounting Documents, Document Type
SPSite Url=https://client/sites/docs, Meeting Minutes, Document Type
SPSite Url=https://client/sites/docs, Documents, Document Type
SPSite Url=https://client/sites/docs, Announcements, Document Type
Script:
[system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint")
$sites = @("https://client",
"https://client/sites/docs");
$cols = @("Document Type",
"Another Column Name",
"My Column",
"Find Me");
foreach($siteurl in $sites){
$site = get-spsite $siteurl
$web=$site.OpenWeb()
$lists=$web.Lists
foreach($list in $lists) {
$fields = $list.Fields
foreach($col in $cols){
if($fields.title -contains $col){
write-output "$site, $list, $col"
}
}
}