다음을 통해 공유


ConvertTo-CliXml

개체를 CliXml 형식 문자열로 변환합니다.

구문

Default (기본값)

ConvertTo-CliXml
    [-InputObject] <PSObject>
    [-Depth <Int32>]
    [<CommonParameters>]

Description

ConvertTo-CliXml cmdlet은 개체를 CLI(공용 언어 인프라) XML 형식의 문자열로 변환합니다. 이 명령은 Export-Clixml비슷하지만 파일에 쓰지 않습니다. 대신 문자열을 출력합니다.

이 cmdlet은 PowerShell 7.5-preview.4에서 도입되었습니다.

예제

예제 1 - 프로세스 개체를 CliXml로 변환 및 뒤로 변환

이 예제에서는 프로세스 개체를 CliXml로 변환하고 뒤로 변환한 결과를 보여줍니다. 먼저 현재 프로세스가 변수 $process저장됩니다. 프로세스 개체의 pstypenames 속성은 개체가 System.Diagnostics.Process 형식임을 보여 줍니다. 다음 명령은 프로세스 개체의 각 멤버 유형에 대한 개수를 표시합니다.

$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

다음으로 프로세스 개체가 CliXml로 변환되고 뒤로 변환됩니다. 새 개체의 형식에는 Deserialized접두사로 지정됩니다. 새 개체의 멤버 수는 원래 개체와 다릅니다.

매개 변수

-Depth

XML 표현에 포함된 개체의 수준을 지정합니다. 기본값은 2입니다.

매개 변수 속성

형식:Int32
Default value:2
와일드카드 지원:False
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-InputObject

CliXml 형식 문자열로 변환할 개체입니다.

매개 변수 속성

형식:PSObject
Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

(All)
Position:0
필수:True
파이프라인의 값:True
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

CommonParameters

이 cmdlet은 일반적인 매개 변수인 -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction 및 -WarningVariable 매개 변수를 지원합니다. 자세한 내용은 about_CommonParameters를 참조하세요.

입력

PSObject

출력

String