我需要选择最大计数和计数以在 PowerShell 中进行计算。
这是 xml 示例:
<Para TimeStamp="1497627698"
Signature="6D09881827E0973">
<License Module="page"
ServerId="1452"
EnterBy="20110630"
RenewDate="20170701"
RenewPeriod="Year"
MaxNumWorkflowServers="1"
MaxVersion="3.0"
MaxNumExportFields="10"
TableRecognition="FALSE"
DisabledOn="20170613">
<Counter Name="Pages"
MaxCount="7500"
Count="7500"/>
</License>
<License Module="page"
ServerId="1452"
EnterBy="20170613"
RenewDate="20170701"
RenewPeriod="Year"
MaxNumWorkflowServers="1"
MaxVersion="3.0"
MaxNumExportFields="10"
TableRecognition="FALSE"
ValidUntil="20170620">
<Counter Name="Pages"
MaxCount="8000"
Count="7613"/>
</License>
</Para>
试试这个:
[xml]$xml = '
<Para TimeStamp="1497627698"
Signature="6D09881827E0973">
<License Module="page"
ServerId="1452"
EnterBy="20110630"
RenewDate="20170701"
RenewPeriod="Year"
MaxNumWorkflowServers="1"
MaxVersion="3.0"
MaxNumExportFields="10"
TableRecognition="FALSE"
DisabledOn="20170613">
<Counter Name="Pages"
MaxCount="7500"
Count="7500"/>
</License>
<License Module="page"
ServerId="1452"
EnterBy="20170613"
RenewDate="20170701"
RenewPeriod="Year"
MaxNumWorkflowServers="1"
MaxVersion="3.0"
MaxNumExportFields="10"
TableRecognition="FALSE"
ValidUntil="20170620">
<Counter Name="Pages"
MaxCount="8000"
Count="7613"/>
</License>
</Para>
'
然后$xml.Para.License.Counter.MaxCount
在你的 Powershell 提示符下执行:这将为您提供 xml 中所有最大计数元素的值。您可以为之后要操作的任何元素指定变量。
或者,如果您的 XML 是一个文件,您可以$xml
使用[xml]$xml = Get-Content [path_to_your_file]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句