I have seen multiple posts on different forums to get details of list columns (like field type) for all SharePoint Lists or any specific list. I also uploaded script to Technet document gallery . This PowerShell script will show the fields defined in list Views. But with a little modification in code you can get details of all fields associated with SharePoint List.
There are two functions in attached PowerShell script:

GetSPFieldDetailsForAllLists:
This function takes one parameter (Site URL), and will print all fields in SharePoint site associated with list views.

function GetSPFieldDetailsForAllLists($SiteCollectionURL) 
{ 
    $site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL) #Change site URL# 
    $web = $site.openweb()  

    foreach ($list in $web.Lists) #Get all list in web 
    { 
        foreach ($view in $list.Views) #Get all views in lists 
        { 
            $spView = $web.GetViewFromUrl($view.Url) #Grab views URL 
            Write-Host "List Name: " $list.Title  ##Print List title 
            Write-Host "------------------------------------------------------" 
            Write-Host "Field Name | Field Title " -ForegroundColor DarkGreen 
            Write-Host "------------------------------------------------------" 
            foreach ($spField in $spView.ViewFields) #Loop through all view URLs and get Fields (columns) 
            { 
                foreach ($field in $list.Fields) #Get all fields in lists 
                { 
                    if($spField -eq $field.Title) #if field in lists equals field in views 
                        { 
                            Write-Host $spField " | " $field.Type -ForegroundColor Green #Write out each field (column)                         
                        } 
                } 
            } 
            Write-Host "------------------------------------------------------" 
            Write-Host " " 
        } 
    } 
    $web.Dispose() 
    $site.Dispose() 
}

Function Call: Function can be called as GetSPFieldDetailsForAllLists http://<siteURL>

GetSPFieldDetailsForList:
This function takes two parameter (Site URL & List name). It’s functionality is same as of GetSPFieldDetailsForAllLists but it will print field details of only single list which is passed as parameter.

function GetSPFieldDetailsForList($SiteCollectionURL, $listName) 
{ 
    $site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL) #Change site URL# 
    $web = $site.openweb()  
    $list = $web.Lists[$listName] #Get Field Details for specified list 

    foreach ($view in $list.Views) #Get all views in lists 
    { 
        $spView = $web.GetViewFromUrl($view.Url) #Grab views URL 
        Write-Host "List Name: " $list.Title  ##Print List title 
        Write-Host "------------------------------------------------------" 
        Write-Host "Field Name | Field Title " 
        Write-Host "------------------------------------------------------" 
        foreach ($spField in $spView.ViewFields) #Loop through all view URLs and get Fields (columns) 
        { 
            foreach ($field in $list.Fields) #Get all fields in lists 
            { 
                if($spField -eq $field.Title) #if field in lists equals field in views 
                { 
                    Write-Host $spField " | " $field.Type -ForegroundColor Green #Write out each field (column)                         
                } 
            } 
        } 
        Write-Host "------------------------------------------------------" 
        Write-Host " " 
    }     
    $web.Dispose() 
    $site.Dispose() 
}

Function Call: Function can be called as GetSPFieldDetailsForList http://<siteURL> <List Name>

Get Details of all fields associated with SharePoint List:
With a little modification in above code, you can get details of all fields associated with List. In above code snippet I have used fields for List view only. For fetching all list fields, you will need to do below modification.

    $site = new-object Microsoft.SharePoint.SPSite("http://<Site URL>") #Change site URL# 
    $web = $site.openweb()  
    $list = $web.Lists["<List Name>"] #Get Field Details for specified list 

    Write-Host "List Name: " $list.Title  ##Print List title 
    Write-Host "------------------------------------------------------" 
    Write-Host "Field Name | Field Title " 
    Write-Host "------------------------------------------------------"         

    foreach ($field in $list.Fields) #Get all views in lists 
    { 
        Write-Host $field.Title " | " $field.Type -ForegroundColor Green #Write out each field (column)                         

    }    
    Write-Host "------------------------------------------------------" 
    Write-Host " "  

    $web.Dispose() 
    $site.Dispose()

Adnan, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose. Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies. Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.

Leave a Reply