$ErrorActionPreference = "Stop"
# get a Core Service client
Import-Module Tridion-CoreService -Verbose:$false
Set-TridionCoreServiceSettings -Version "Web-8.1" -HostName localhost -ConnectionType Basic
$client = Get-TridionCoreServiceClient
# get the parent schema to edit
$schemaId = "tcm:21-4247-8"
$schema = Get-TridionItem $schemaId
# change the InterestArea embedded component root element name
[xml] $xmlSchema = $schema.Xsd
$ns = @{xsd="http://www.w3.org/2001/XMLSchema"}
#to be extra careful to update the right thing you could use this: $xpath = "//xsd:element[@name='MarketingStory'][@type='Section']"
$xpath = "//xsd:element[@name='MarketingStory']" # this is the XML fieldname in the parent schema
$element = $xmlSchema | Select-Xml -XPath $xpath -Namespace $ns
if($element -eq $null)
{
Write-Error "Did not find element $xpath"
}
$element.Node.type = "Section" # this is the root element name from the embedded schema
$schema.Xsd = $xmlSchema.OuterXml
# save the schema
$readBackOptions = New-Object Tridion.ContentManager.CoreService.Client.ReadOptions
$updatedSchema = $client.Update($schema, $readBackOptions)
Write-Host "Saved updated schema"
# you can read and verify the changed schema
#$schema.Xsd