Powershell 2.0从msinfo32.exe解析xml [英] Powershell 2.0 to parse xml from msinfo32.exe

查看:79
本文介绍了Powershell 2.0从msinfo32.exe解析xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我知道msinfo32.exe文件中的信息可以通过本机Powershell命令行开关获得。但是,我特别需要从msinfo32.txt文件中解析两个或三个属性的数据。



因为文件是xml格式,我想我会尝试使用Powershell来检索数据。





我已将文件内容添加到变量($ msinfo):



[xml] $ msinfo =获取内容msinfo32-TEMPLATE.nfo





我读到最后的'数据'孩子,但我不知道如何选择我感兴趣的价值...



PS C:\ temp \ xml> $ msinfo.MsInfo.Category



名称数据类别

---- ----- ------

系统摘要{数据,数据,数据,数据... {硬件资源,C ...






PS C:\ temp \ xml> $ msinfo.MsInfo.Category



名称数据类别

---- ----- ------

系统摘要{数据,数据,数据,数据... {硬件资源,C ......








我查看了MSDN的book.xml文件并用它来检查信息,它似乎做我需要的。



我有点困惑,任何指向需要的文章/链接的指针都将不胜感激。

解决方案

msinfo):



[xml]


msinfo = Get-Content msinfo32-TEMPLATE .nfo





我读到最后的'数据'孩子,但我不知道如何选择我感兴趣的值...



PS C:\ temp \ xml>


msinfo.MsInfo.Catego ry



名称数据类别

---- ---- ------- -

系统摘要{数据,数据,数据,数据... {硬件资源,C ......






PS C:\ temp \ xml>


Hi,

I do know that the info found in the msinfo32.exe file is available via native Powershell commandlets. However, I have a particular need to parse the data from a msinfo32.txt file for two or three attributes.

As the file is an xml format, I thought I would try using Powershell to retrieve the data.


I've added the contents of the file to a variable ($msinfo):

[xml]$msinfo = Get-Content msinfo32-TEMPLATE.nfo


I get as far as reading the final 'Data' child, however I am not sure how to select values I'm interested in...

PS C:\temp\xml> $msinfo.MsInfo.Category

name Data Category
---- ---- --------
System Summary {Data, Data, Data, Data... {Hardware Resources, C...



PS C:\temp\xml> $msinfo.MsInfo.Category

name Data Category
---- ---- --------
System Summary {Data, Data, Data, Data... {Hardware Resources, C...




I've looked at MSDN's book.xml file and used that to check info, and it seems to do what I need.

I'm slightly confused and any pointers to an article / link explaining what is needed, would be appreciated.

解决方案

msinfo):

[xml]


msinfo = Get-Content msinfo32-TEMPLATE.nfo


I get as far as reading the final 'Data' child, however I am not sure how to select values I'm interested in...

PS C:\temp\xml>


msinfo.MsInfo.Category

name Data Category
---- ---- --------
System Summary {Data, Data, Data, Data... {Hardware Resources, C...



PS C:\temp\xml>


这篇关于Powershell 2.0从msinfo32.exe解析xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆