如何反序列化此PowerShell输出?

时间:2016-11-28 21:00:38

标签: xml powershell sccm

@bitrate

PS sss:\> $match.ApplicabilityCondition <ApplicabilityRule ExpressionLanguage="Custom" Handler="{2DB70103-3DFB-4806-85B0-B27B561284BB}"><UpdateId>3a50171e-f09b-46fd-991c-ffa0c1fabcc6</UpdateId><CISource><Id>{7ABE2526-ED91-47AE-A989-275B4B2924FE}</Id><Version>188</Version></CISource><ProductId>704a0a4a-518f-4d69-9e03-10ba44198bd5</ProductId></ApplicabilityRule> 是一个类似XML的对象,它作为ApplicabilityCondition(与SCCM相关的命令)的一部分返回。 Get-CMSoftwareUpdate对我没有任何意义。有没有一种简单的方法可以引用显示的子属性?最终我试图获得ExpressionLanguage="Custom"

1 个答案:

答案 0 :(得分:5)

我认为您可以将其解析为XML

请参阅:

$xml = [xml]'<ApplicabilityRule ExpressionLanguage="Custom" Handler="{2DB70103-3DFB-4806-85B0-B27B561284BB}">
    <UpdateId>3a50171e-f09b-46fd-991c-ffa0c1fabcc6</UpdateId>
    <CISource>
        <Id>{7ABE2526-ED91-47AE-A989-275B4B2924FE}</Id>
        <Version>188</Version>
    </CISource>
    <ProductId>704a0a4a-518f-4d69-9e03-10ba44198bd5</ProductId>
</ApplicabilityRule>'

$xml.ChildNodes

返回:

ExpressionLanguage : Custom
Handler            : {2DB70103-3DFB-4806-85B0-B27B561284BB}
UpdateId           : 3a50171e-f09b-46fd-991c-ffa0c1fabcc6
CISource           : CISource
ProductId          : 704a0a4a-518f-4d69-9e03-10ba44198bd5