3

Is there a way in SharePoint Online to get Field Properties? For example, I have a lookup column and for this I want its Field Type, Required, Get information from:
Allow Multiple Values: Checked or not, Description. I know we can get it like this:

$context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$context.Credentials = $creds
$web = $context.Web
$list=$web.Lists.GetByTitle($listName);
$fieldColl=$list.Fields;
$context.Load($fieldColl);
$context.ExecuteQuery();
foreach($field in $fieldColl)
{
    Write-Host $field.Title    
    Write-Host $field.Description
}

But I want the other properties as well.

1

3 Answers 3

4

You could get field properties like this:

$columns = Get-PnPField -List "PnPList"  
foreach($column in $columns){  
    Write-Host "Column Title  :" $column.Title  
    Write-Host "Description   :" $column.Description  
    Write-Host "Group Name    :" $column.Group  
    Write-Host "Internal Name :" $column.InternalName  
    Write-Host "Static Name   :" $column.StaticName  
    Write-Host "Scope         :" $column.Scope  
    Write-Host "Type          :" $column.TypeDisplayName  
    Write-Host "Schema XML    :" $column.SchemaXml  
    Write-Host "Is Required?  :" $column.Required  
    Write-Host "Is read only? :" $column.ReadOnlyField  
    Write-Host "Unique?       :" $column.EnforceUniqueValues  
    Write-Host "-------------------------------------------"  
}   

And for detailed definition, you could check the SchemaXml, it will have all property definition.

EDIT : Script source

2
  • 4
    When you take answer from the internet, please credit them. Plagiarism is not a joke. Source for this: c-sharpcorner.com/article/…
    – moe
    Commented Jul 20, 2018 at 10:30
  • Is there any way to get the ID for each listed property in the schema within the choice tags? Surely there is a consistent ID associated. Commented Mar 13, 2019 at 17:42
2

You can do this easily with PnP PowerShell using the Get-PnPField commandlet:

So something like this:

Connect-PnPOnline https://yourtenant.sharepoint.com/sites/yoursite
Get-PnPField -List "Your List Name"
Disconnect-PnPOnline

You can also get this information via REST by visiting:

https://yoursite.sharepiont.com/sites/yoursites/_api/web/lists/getbytitle('Your List Name')/fields
-1

Finally I ended up using site provisioning to transfer over my columns and content types over to the Content Type Hub.

Login through PnP PowerShell

Get-PnPProvisioningTemplate -out “youroutputfile.xml” –Handlers “Fields,ContentTypes”

Find the file ouput. Defauld be C:\Windows\System32

Connect to the Hub Connect-PnPOnline https://yoursite.sharepoint.com/sites/contentTypeHub

Apply the provisioned file Apply-PnPProvisioningTemplate C:\Temp\youroutputfile.xml

That's it!

1
  • Welcome to SharePoint.stackexchange.com. Thanks for contributing! I'm not sure how what you wrote about the content type hub directly answers the question about field properties. Did you mean to answer a different question?
    – Tom Resing
    Commented Jan 7, 2019 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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