I am trying to create a new PublicationTarget with PowerShell, using the 2010 CoreService interface.
I have to following code within a function (separated for clarity):
(first block of code, seems to be correct)
$newTarget = $client.getdefaultdata([core.ItemType]::PublicationTarget, $true, $readOptions)
$newTarget.title = $type.title
$newTarget.description = $type.description
$newTarget.targetlanguage = "JSP"
(second block of code, unsure where to add what...)
$schema = new-object core.SchemaData
$link = new-object core.LinkToSchemaData
$link.idref = $schema
$link.title = "my link schema title"
(third block of code, unsure what to do with it...)
$protocol = new-object System.Xml.XmlDocument
$protocol.loadxml("<Local xmlns=`"http://www.tridion.com/ContentManager/5.0/Protocol/LocalFileCopy`"><Location>c:\temp</Location></Local>")
(fourth block of code, seems correct to me)
$dest = new-object core.TargetDestinationData
$dest.protocolschema = $link
$dest.protocoldata = $protocol
(last block, glueing everthing together)
$newTarget.destinations = $dest
$result = $client.create($newTarget, $readOptions)
Code for the allowed publications and allowed target types is still missing.
There is something missing, I guess, in the SchemaData (second block), but what?
There is something wrong, in the $protocol definition, because of the error message:
"The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://www.sdltridion.com/ContentManager/CoreService/2010:data.
The InnerException message was 'There was an error deserializing the object of type Tridion.ContentManager.Data.IdentifiableObjectData.
Data at the root level is invalid.
I hope someone can point me into the right direction to fix the error message.