【发布时间】:2014-06-01 19:36:33
【问题描述】:
我想要一个使用Format-Table 来显示对象的C# 控制台程序。这是一个简单的 C# 程序:
using System;
using System.Collections.Generic;
using System.Text;
using System.Management.Automation;
namespace PowerShellFormatTableTest
{
class Program
{
static void Main(string[] args)
{
var ps = PowerShell.Create()
.AddCommand("Get-Process")
.AddCommand("Format-Table");
foreach (var result in ps.Invoke())
{
// ...
}
}
}
}
大部分result 元素当然是FormatEntryData 对象。
有没有办法将Format-Table 格式的输出打印到控制台?
上面的例子只是一个简单的例子。通常,我会传递任意对象
【问题讨论】:
标签: c# .net powershell cmdlets