Skip to content

Scriptblocks serialized to Clixml are deserialized as strings #4218

@hmmwhatsthisdo

Description

@hmmwhatsthisdo

ScriptBlock objects are deserialized as strings when run through Import-CliXml.

@nightroman has a more detailed test case on his PowerShellTraps repo, including a link to a Microsoft Connect issue from March of 2015. This appears to have been migrated to the Windows Server UserVoice, but the issue still exists in v6.0.0-beta.3.

Steps to reproduce

{Get-Process} | Export-Clixml .\Test.clixml

Import-Clixml .\Test.Clixml | % GetType

Expected behavior


IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     ScriptBlock                              System.Object

Actual behavior


IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
GitCommitId                    v6.0.0-beta.3
OS                             Microsoft Windows 10.0.15063
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-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifIssue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions