I am looking for a way to change a managed metadata column from single entry to multiple entry using Powershell. Any help would be appreciated. Using SharePoint Online.
Thanks.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI am looking for a way to change a managed metadata column from single entry to multiple entry using Powershell. Any help would be appreciated. Using SharePoint Online.
Thanks.
The PowerShell below for your reference:
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"
#set parameters
$webURL="https://xxx.sharepoint.com/sites/test"
$UserName= "test@xxx.onmicrosoft.com"
$Password = "***"
$listName="customlist"
$fieldName="TestMM"
$credentials= New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
$ctx= New-Object Microsoft.SharePoint.Client.ClientContext($webURL)
$ctx.Credentials = $credentials
$oList = $ctx.Web.Lists.GetByTitle($listName)
$field = $oList.Fields.GetByTitle($fieldName)
$ctx.Load($field)
$ctx.ExecuteQuery()
#Remove the node if it exists, and add again
$fieldXml = $field.SchemaXml.Replace('Mult="FALSE"', '')
$field.SchemaXml = $fieldXml.Replace('Type="TaxonomyFieldType"', 'Type="TaxonomyFieldTypeMulti" Mult="TRUE" Sortable="FALSE"')
$field.Update()
$ctx.ExecuteQuery()