3

I need to get all the choice options on a SharePoint Online List with PowerShell. I can find many sample scripts for on-premise SharePoint but I cannot convert them successfully in SharePoint Online. Could you please advise which PS module and script I can get the choices option for SPO?

2 Answers 2

3

I would suggest using PnP PowerShell. Here are some resources that will help you get started.

PnP PowerShell

Installing PnP PowerShell

Connecting with PnP PowerShell

I have a site that has a list named Choices Test. This list has a choice column named Color with three choices: Red, Green, and Blue. I can use PnP PowerShell to get those choice values from the column.

Connect-PnPOnline -Url https://robwindsortest986.sharepoint.com/sites/Demo
$field = Get-PnPField -List "Choices Test" -Identity "Color"
[xml]$schemaXml = $field.SchemaXml
$schemaXml.Field.CHOICES

PowerShell screen capture

1

Adding to Rob's answer, the values can also be extracted from the TypedObject property:

$column = Get-PnPField -List $list_name -Identity "TestChoice"
$column.TypedObject.Choices # these are the field choices

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.