如何将Powershell脚本的结果存储到XML文件中 [英] How to store a result of a powershell script into a XML File

查看:197
本文介绍了如何将Powershell脚本的结果存储到XML文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我正在开发一个Web服务,用于通过使用C#.net运行Power Shell脚本.我正在以XML文件形式获取输入,使用C#.net可以轻松获得所需的查询.但是当我执行powershell脚本时,它返回字符串值.我需要XML文件.

例如:Get-EventLog -LogName应用程序"

我需要将此结果存储到XML文件中.

Hi Friends,

I am developing a web service for running power shell scripts by using C#.net. I am getting a input as XML file, it is easy to get the required query using C#.net. But when i executing the powershell script, it returns string value. I need XML file.

Eg: Get-EventLog -LogName ''Application''

I need to store this result into a XML File.

Please reply for this.

推荐答案

v2.0中存在一个ConvertTo-XML cmdlet:
http://technet.microsoft.com/en-us/library/ff730921.aspx [ ^ ]

也有Export-Clixml cmdlet

干杯
A ConvertTo-XML cmdlet exists in v2.0 :
http://technet.microsoft.com/en-us/library/ff730921.aspx[^]

Also there is the Export-Clixml cmdlet

Cheers


这篇关于如何将Powershell脚本的结果存储到XML文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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