This script is intend to get all the fields and internal name from a list. Sometimes you might get into a situation where you have changed the column name in a list but that is not reflecting in item properties.

#Config Variables
$SiteURL = https://expertbrains.sharepoint.com
$ListName ="Finance"
 
#Get Credentials to connect
$Cred = Get-Credential
 
Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Credentials $Cred
     
    #Get All Columns from List
    Get-PnPField -List $ListName
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}