Skip to content

Export-CliXml - issue with $PSVersionTable xml tag when importing CliXml to psobject . #6448

@MaximoTrinidad

Description

@MaximoTrinidad

Ok! Heard me out. While I was playing around with PowerShell Studio to create a form to display results coming from $PSversionTable in PSCore6 psobjects exported to clixml to then import to a psobject in Windows PowerShell.

I found out the Import-CliXml will error out in Windows PowerShell with the following message:

Import-Clixml : SemanticVersion XML tag is not recognized. Line 81, position 8.
At line:1 char:10
+ $psobj = Import-Clixml -Path c:\Temp\pwshobject602.xml;
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Clixml], XmlException
    + FullyQualifiedErrorId : System.Xml.XmlException,Microsoft.PowerShell.Commands.ImportClixmlCommand

Of course, this is not a Windows PowerShell issue as the workaround below works.

WorkAround

Via code I had to fix the xml tag;

:
 $line.Replace('SemanticVersion', 'Version');
:

psverxml_012018-03-21_11-17-46

After fixing the xml tag then my application works. This only happens with the $PSVersionTable.

pss2018_pwshcore_win01_2018-03-21_10-53-04

Steps to reproduce

## - Execute in PSCore 6.0.2:
(Get-Variable PSVersionTable).value.GetEnumerator()| Export-Clixml -Path c:\Temp\pwshobject602.xml;

## - Execute in Windows PowerShell:
$psobj = Import-Clixml  -Path c:\Temp\pwshobject602.xml;
Import-Clixml : SemanticVersion XML tag is not recognized. Line 81, position 8.
At line:1 char:10
+ $psobj = Import-Clixml -Path c:\Temp\pwshobject602.xml;
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Clixml], XmlException
    + FullyQualifiedErrorId : System.Xml.XmlException,Microsoft.PowerShell.Commands.ImportClixmlCommand

Expected behavior

To import the CliXml to a PSobject without any error.

Actual behavior

Error: "Import-Clixml : SemanticVersion XML tag is not recognized. Line 81, position 8."

Environment data

## - PSCore6:
PS [156] > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.2
PSEdition                      Core
GitCommitId                    v6.0.2
OS                             Microsoft Windows 10.0.17127
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions