C#Powershell结果 [英] C# Powershell results

查看:68
本文介绍了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.

推荐答案

请确定您正在使用的UI技术,以便我们将此问题移至相应的论坛。
Please identify what UI technology you are using so we can move this question to the appropriate forums.


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

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