Load xml (xmlable string) in powershell

Hi Support team,

I would just like to ask regarding loading xml in powershell script.

I have created a list content (with content type mapping) job configuration in Metalogix Content Matrix UI , and generated a powershell script for it.

From it, i have decided to modify it, put the xml part in the code (with <xmlableset></xmlableset> xmlcode) in a  in a txt file, wherein it will be loaded in the pshell script and assign in variable ($xmlMapping), then consume in the line below:

$SourceCollection | Copy-MLAllSharePointSiteContent -Target $Target  -CopyLists -UpdateSites "CoreMetaData","SiteColumns","Permissions","PermissionLevels","ContentTypes","Navigation","WebParts","Features","AssociatedGroups" -CopyUncustomizedFiles -CopyGlobalNavigation -CopyCurrentNavigation -UpdateLists "All" -CheckModifiedDatesForLists -CopyCustomizedFormPages -CopyFormWebParts -CopyListItems -OverwriteItems -CheckModifiedDatesForItemsDocuments -UpdateItems "All" -CopyVersions -CopySubFolders -MaximumVersionCount "1" -ContentTypeApplicationObjects ( New-MetalogixSerializableObject "Metalogix.DataStructures.Generic.CommonSerializableList``1[[Metalogix.SharePoint.Options.Migration.ContentTypeApplicationOptionsCollection, Metalogix.SharePoint.Options, Version=9.1.0.1, Culture=neutral, PublicKeyToken=3b240fac3e39fc03]]" "Metalogix.Core" $xmlMapping -Enumerate) -MigrationMode "Custom" -MapAudiences -VerboseLog -LogSkippedItems -ForceRefresh -CorrectingLinks -LinkCorrectTextFields -LinkCorrectionScope "SiteCollection" -UseComprehensiveLinkCorrection -MapMissingUsersToLoginName "" .....

PREVIOUS SCRIPT was like this:

$SourceCollection | Copy-MLAllSharePointSiteContent -Target $Target  -CopyLists -UpdateSites "CoreMetaData","SiteColumns","Permissions","PermissionLevels","ContentTypes","Navigation","WebParts","Features","AssociatedGroups" -CopyUncustomizedFiles -CopyGlobalNavigation -CopyCurrentNavigation -UpdateLists "All" -CheckModifiedDatesForLists -CopyCustomizedFormPages -CopyFormWebParts -CopyListItems -OverwriteItems -CheckModifiedDatesForItemsDocuments -UpdateItems "All" -CopyVersions -CopySubFolders -MaximumVersionCount "1" -ContentTypeApplicationObjects ( New-MetalogixSerializableObject "Metalogix.DataStructures.Generic.CommonSerializableList``1[[Metalogix.SharePoint.Options.Migration.ContentTypeApplicationOptionsCollection, Metalogix.SharePoint.Options, Version=9.1.0.1, Culture=neutral, PublicKeyToken=3b240fac3e39fc03]]" "Metalogix.Core" "<XmlableSet><XmlableItem Type=`"Metalogix.SharePoint.Options.Migration.ContentTypeApplicationOptionsCollection, Metalogix.SharePoint.Options, Version=9.1.0.1, Culture=neutral, PublicKeyToken=3b240fac3e39fc03`"><ContentTypeApplicationOptionsCollection Type=`"Metalogix.SharePoint.Options.Migration.ContentTypeApplicationOptionsCollection, Metalogix.SharePoint.Options, Version=9.1.0.1, Culture=neutral, PublicKeyToken=3b240fac3e39fc03`" AddUnmappedItemsToDefaultContentType=`"False`" RemoveAllOtherContentTypes=`"True`">...

However, when i did run the script, there is an error display, whcih i assume, the loaded xml string was not assigned correctly:

Error: Converting an XML string to node failed. The input string is:
'<XmlableSet><XmlableItem Type=`"Metalogix.SharePoint.Options.Migration.ContentTypeApplicationOptionsCollection, Metalogix.SharePoint.Options, Version=9.1.0.1, Culture=neutral, PublicKeyToken=3b240fac3e39fc03`"><ContentTypeApplicationOptionsCollection Type=`"Metalogix.SharePoint.Options.Migration.ContentTypeApplicationOptionsCollection, Metalogix.SharePoint.Options, Version=9.1.0.1, Culture=neutral, PublicKeyToken=3b240fac3e39fc03`" AddUnmappedItemsToDefaultContentType=`"False`" RemoveAllOtherContentTypes=`"True`"><AppliesToFilter><FilterExpression><Equals Property=`"DisplayUrl`" CaseSensitive=`"False`" BaseFilter=`"False`" Pattern=`"">neogigabitzcom.sharepoint.com/.../AppliesToFilter><ColumnMappings><ColumnMappingsList AutoMapCreatedAndModified=`"False`"><FieldsFilter><And IsImplicitGroup=`"True`" /></FieldsFilter><XmlableSet><XmlableItem Type=`"Metalogix.Data.Mapping.ListSummaryItem, Metalogix.Explorer, Version=9.1.0.1, Culture=neutral, PublicKeyToken=3b240fac3e39fc03`"><ListSummaryItem Group=`"Site Column`"><CustomColumns><XmlableTable /></CustomColumns><Source><ListPickerItem Group=`"`" Target=`"ContentType`" TargetType=`"Computed`"><CustomColumns><XmlableTable /></CustomColumns><Tag IsNew=`"False`" Type=`"Metalogix.SharePoint.SPField, Metalogix.SharePoint, Version=9.1.0.1, Culture=neutral, PublicKeyToken=3b240fac3e39fc03`"><Field ID=`"{c042a256-787d-4a6f-8a8a-cf6ab767f12d}`" Name=`"ContentType`" SourceID=`"">schemas.microsoft.com/.../v3`" StaticName=`"ContentType`" Group=`"_Hidden`" Type=`"Computed`" DisplayName=`"Content Type`" Sortable=`"FALSE`" RenderXMLUsingPattern=`"TRUE`" PITarget=`"MicrosoftWindowsSharePointServices`" PIAttribute=`"ContentTypeID`" DelayActivateTemplateBinding=`"GROUP,SPSPERS,SITEPAGEPUBLISHING`" DisplaceOnUpgrade=`"TRUE`" FromBaseType=`"TRUE`" Sealed=`"FALSE`" Version=`"1`"><FieldRefs><FieldRef ID=`"{03e45e84-1992-4d42-9116-26f756012634}`" Name=`"ContentTypeId`" /></FieldRefs><DisplayPattern><MapToContentType><Column Name=`"ContentTypeId`" /></MapToContentType></DisplayPattern></Field></Tag></ListPickerItem></Source><Target><ListPickerItem Group=`"`" Target=`"ContentType`" TargetType=`"Computed`"><CustomColumns><XmlableTable /></CustomColumns><Tag IsNew=`"False`" Type=`"Metalogix.SharePoint.SPField, Metalogix.SharePoint, Version=9.1.0.1, Culture=neutral, PublicKeyToken=3b240fac3e39fc03`"><Field ID=`"{c042a256-787d-4a6f-8a8a-cf6ab767f12d}`" Name=`"ContentType`" SourceID=`"">schemas.microsoft.com/.../v3`" StaticName=`"ContentType`" Group=`"_Hidden`" Type=`"Computed`" DisplayName=`"Content Type`" Sealed=`"TRUE`" Sortable=`"FALSE`" RenderXMLUsingPattern=`"TRUE`" PITarget=`"MicrosoftWindowsSharePointServices`" PIAttribute=`"ContentTypeID`" DelayActivateTemplateBinding=`"GROUP,SPSPERS,SITEPAGEPUBLISHING`"><FieldRefs><FieldRef ID=`"{03e45e84-1992-4d42-9116-26f756012634}`" Name=`"ContentTypeId`" /></FieldRefs><DisplayPattern><MapToContentType><Column Name=`"ContentTypeId`" /></MapToContentType></DisplayPattern></Field></Tag></ListPickerItem></Target></ListSummaryItem></XmlableItem><XmlableItem Type=`"Metalogix.Data.Mapping.ListSummaryItem, Metalogix.Explorer, Version=9.1.0.1, Culture=neutral, PublicKeyToken=3b240fac3e39fc03`"><ListSummaryItem Group=`"Site Column`"><CustomColumns><XmlableTable /></CustomColumns><Source><ListPickerItem Group=`"`" Target=`"TCT_CorporateProjectPhase`".....

I would like to know how this xml string will be passed onto my script and load the xml string correctly. Please advise. Thanks for the help.

Regards,

- Bryan

  • Hello Bryan,

    Via Support the assistance of modifying the auto-generated using additional variables is outside scope of support if you were to create a Support Ticket.

    This looks like a PowerShell issue with your variable and how you are adding it to the PowerShell script.

     

    This is probably how you have you setup below except pointing to a TXT file:

    $xmlMapping = "<xmlableset>Adding Information in TextFile</xmlableset>"

    When I think you might get better luck if you were to set the variable like below:

    $xmlMapping = "Adding Information in TextFile"

    And then add it to the PowerShell Script like this

    <xmlableset>$xmlMapping</xmlableset>

    This all being said, I am not sure if the above would work for you, it is a bit of a guess on my part.

    Best Regards

    Wes