Forum Discussion
jbtzz
Mar 21, 2023Brass Contributor
Identify site columns in lists
Good day, Is there a way to know which columns in a list are actually site columns and not "locally" created list columns?
- Mar 22, 2023
I figured it out by using PowerShell PnP:
#Parameters $SiteURL = "https://YourDomain.sharepoint.com/sites/YourSite" $ListName = "YourListName" #Connect to source SharePoint Connect-PnPOnline -Url $SiteURL -Interactive #Get list and site columns to compare Ids $ListFields = Get-PnPField -List $ListName $SiteFields = Get-PnPField Foreach($l in $ListFields | where {$_.Hidden -eq $false}){ $counter = 0 Foreach($s in $SiteFields){ if($l.Id -eq $s.Id) { echo "$($l.Title) (Internal name: $($l.InternalName)) is a SITE COLUMN" $counter++ } } if($counter -eq 0){ echo "$($l.Title) (Internal name: $($l.InternalName)) is a LIST COLUMN" } }
jbtzz
Mar 22, 2023Brass Contributor
I figured it out by using PowerShell PnP:
#Parameters
$SiteURL = "https://YourDomain.sharepoint.com/sites/YourSite"
$ListName = "YourListName"
#Connect to source SharePoint
Connect-PnPOnline -Url $SiteURL -Interactive
#Get list and site columns to compare Ids
$ListFields = Get-PnPField -List $ListName
$SiteFields = Get-PnPField
Foreach($l in $ListFields | where {$_.Hidden -eq $false}){
$counter = 0
Foreach($s in $SiteFields){
if($l.Id -eq $s.Id) {
echo "$($l.Title) (Internal name: $($l.InternalName)) is a SITE COLUMN"
$counter++
}
}
if($counter -eq 0){
echo "$($l.Title) (Internal name: $($l.InternalName)) is a LIST COLUMN"
}
}