本文介绍了C#Powershell结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻求有关将powershell中的集合添加到数据网格中的帮助。到目前为止我有类似的东西..

Looking for help on adding a collection from powershell into a datagrid. I have something like this so far..

PowerShell ps = PowerShell.Create();
$
ps.Runspace = RunspaceFactory.CreateRunspace();

ps.Runspace.Open();

ps.AddScript(" Get-Process | FT Name,ProcessName");

var results = ps .Invoke();
$
dataGridView1.DataSource = results;

PowerShell ps = PowerShell.Create();
ps.Runspace = RunspaceFactory.CreateRunspace();
ps.Runspace.Open();
ps.AddScript("Get-Process | FT Name, ProcessName");
var results = ps.Invoke();
dataGridView1.DataSource = results;

我的数据网格有2列,ID& ProcessName。尝试以相同的方式将powershell命令的结果添加到datagrid。

My datagrid has 2 columns, ID & ProcessName. Trying to add the results from the powershell command to the datagrid in that same fashion.

推荐答案


这篇关于C#Powershell结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:19