I'm using ModernUI for SharePoint Online. I'd like to get all List and Library's ColumnName, Type, InternalName in my site by PnP PowerShell. I did some research myself, but I didn't understand, so I would appreciate it if you could teach me how to do it. Thank you for any information. Thank you.

2 Answers 2


1.Download SharePoint Online Management Shell.

2.Try below PowerShell as administrator.

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Function Get-SPOListFields()
        [Parameter(Mandatory=$true)] [string] $SiteURL,
        [Parameter(Mandatory=$true)] [string] $ListName
    Try {
        $Cred= Get-Credential
        $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials
        #Get the List
        $Lists = $Context.web.Lists
        #Array to hold result
        $FieldData = @()   
        ForEach($List in $Lists)
          Foreach ($Field in $List.Fields)
            Write-Host $List.Title `t $Field.Title `t $Field.InternalName `t 
            #Send Data to object array
            $FieldData += New-Object PSObject -Property @{
                    'List Title' = $List.Title
                    'Field Title' = $Field.Title                                       
                    'Internal Name' = $Field.InternalName
                    'Type' = $Field.TypeDisplayName
                    'Schema' = $Field.SchemaXML
        Return $FieldData
    Catch {
        write-host -f Red "Error Getting Fields from List!" $_.Exception.Message
#Set parameter values
$SiteURL="site collection URL"    
$CSVLocation ="local drive"
#Call the function to get all list fields
$FieldData | Export-Csv $CSVLocation -NoTypeInformation
  • Thank you very much!! It works. But I'd like to do this for all List and Library. I don't want to specify a specific list. In that case, Do you have any script?
    – Hyonta
    Jan 1, 2021 at 11:54
  • I have updated the PowerShell. Please check. Jan 4, 2021 at 10:14
Connect-PnPOnline https://tenantName.sharepoint.com/sites/siteName -PnPManagementShell

$lists = Get-PnPList -Includes Fields

foreach($list in $lists)
    $list.Fields | select title,internalname,typeasstring
  • Thank you very much!! It works very well. What if I want to output the list name as well?
    – Hyonta
    Jan 2, 2021 at 8:13
  • Add $list.Title in the foreach loop.
    – Trevor Seward
    Jan 2, 2021 at 18:42
  • I did like this $list.Fields | select title,internalname,typeasstring,$list.Title. But I got listname just one.
    – Hyonta
    Jan 3, 2021 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.