Hello,
I faced problem with change SchemaXML of ManageMetadata (taxonomy) field using CSOM. During run I not receive any errors so investigation is very hard...
Because of Manage Metadata Service structure change I need to update SSPID ( so term store ID) inside each taxonomy fields from old SSP ID =>$regex = 'b31429cc-688c-4393-bcb7-b60cf631ca42' to new SSP ID => [string]$abc = "13e722c5-bebe-4801-a6ac-67aa35eba088"
SCRIPT:
$16Hive = "C:\DLLs"
Add-Type -Path "$16Hive\Microsoft.SharePoint.Client.dll" Add-Type -Path "$16Hive\Microsoft.SharePoint.Client.Runtime.dll" $url = "https://contoso.sharepoint.com/sites/somesite" $User = "myaccount@contoso.onmicrosoft.com" $Password = Read-host -Prompt "Please enter your password" -AsSecureString $officeClientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url) $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password) $officeClientContext.Credentials = $Creds return $officeClientContext $logger = new-object System.Text.StringBuilder function Log($message) { Write-Host $message [void]$logger.AppendLine($message) } $web = $officeClientContext.Web $officeClientContext.Load($web) $fields = $web.Fields $officeClientContext.Load($fields) $officeClientContext.ExecuteQuery() $corruptedFields = $fields | ? { $_.TypeDisplayName -like "*Managed Metadata*" } Log $("Fix SiteColumns for site: " + $officeClientContext.Url) foreach($field in $corruptedFields) { if ($field.SchemaXml.Contains('SspId')) { $regex = 'b31429cc-688c-4393-bcb7-b60cf631ca42' if ($($field.SchemaXml -match $regex)) { $matchedValue = $matches.Values Log $("Change schema " + $matchedValue) [string]$abc = "13e722c5-bebe-4801-a6ac-67aa35eba088" $field.SchemaXml = $field.SchemaXml.Replace($matchedValue, $abc) } } $field.Update() $officeClientContext.ExecuteQuery() }return $logger.ToString()
Thanks for help.