ConvertFrom-CliXml

Converts a CliXml-formatted string to a custom PSObject.

语法

Default (默认值)

ConvertFrom-CliXml
    [-InputObject] <String>
    [<CommonParameters>]

说明

The ConvertFrom-CliXml cmdlet converts strings that are formatted as Common Language Infrastructure (CLI) XML to a custom PSObject. This command is similar to Import-Clixml, but it doesn't read from a file. Instead, it takes a string as input.

The newly deserialized objects aren't live objects. They're a snapshot of the objects at the time of serialization. The deserialized objects include properties but no methods. The pstypenames property contains the original type name prefixed with Deserialized.

This cmdlet was introduced in PowerShell 7.5-preview.4.

示例

Example 1 - Convert a process object to CliXml and back

This example shows the result of converting a process object to CliXml and back. First, the current process is stored in the variable $process. The pstypenames property of the process object shows that the object is of type System.Diagnostics.Process. The next command displays the count for each type of member in the process object.

$process = Get-Process -Id $PID
$process.pstypenames
System.Diagnostics.Process
System.ComponentModel.Component
System.MarshalByRefObject
System.Object
$process | Get-Member | Group-Object MemberType | Select-Object Name, Count
Name           Count
----           -----
AliasProperty      7
CodeProperty       1
Property          52
NoteProperty       1
ScriptProperty     8
PropertySet        2
Method            19
Event              4
$xml = $process | ConvertTo-CliXml
$fromXML = ConvertFrom-CliXml $xml
$fromXML.pstypenames
Deserialized.System.Diagnostics.Process
Deserialized.System.ComponentModel.Component
Deserialized.System.MarshalByRefObject
Deserialized.System.Object
$fromXML | Get-Member | Group-Object MemberType | Select-Object Name, Count
Name         Count
----         -----
Property        46
NoteProperty    17
PropertySet      2
Method           2

Next, the process object is converted to CliXml and back. The type of the new object is prefixed with Deserialized. The count of members in the new object is different from the original object.

参数

-InputObject

The object containing a CliXml-formatted string to be converted.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:0
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

输入

String

输出

Object