C# 为什么可以';从c中的Powershell.Invoke()方法返回所有cimsession函数#
我正在从Powershell和C#运行C# 为什么可以';从c中的Powershell.Invoke()方法返回所有cimsession函数#,c#,powershell,psobject,C#,Powershell,Psobject,我正在从Powershell和C#运行New CimSession命令。当我在Powershell上运行它时,CimSession变量有很多函数,比如TestConnection(),CreateInstance等等。。图片如下 但是,CimSession变量类型的PSObject除了ToString()和GetType()之外,没有其他函数,当我在c#中运行New CimSession命令时 我想从c#上的PSObject变量访问相同的方法。 你有什么想法吗? 添加对Microsoft.Ma
New CimSession
命令。当我在Powershell上运行它时,CimSession变量有很多函数,比如TestConnection()
,CreateInstance
等等。。图片如下
但是,CimSession
变量类型的PSObject
除了ToString()
和GetType()
之外,没有其他函数,当我在c#中运行New CimSession
命令时
我想从c#上的PSObject
变量访问相同的方法。
你有什么想法吗?- 添加对Microsoft.Management.Infrastructure命名空间的引用
- 添加“使用Microsoft.Management.Infrastructure”李>
c会话
将可以访问所需的不同方法
此处引用:
- “C:\Program Files(x86)\Reference Assembly\Microsoft\WMI\v1.0\Microsoft.Management.Infrastructure.dll”
- C:\Windows\Microsoft.NET\assembly\GAC\U MSIL\Microsoft.Management.Infrastructure
- 添加对Microsoft.Management.Infrastructure命名空间的引用
- 添加“使用Microsoft.Management.Infrastructure”李>
c会话
将可以访问所需的不同方法
此处引用:
- “C:\Program Files(x86)\Reference Assembly\Microsoft\WMI\v1.0\Microsoft.Management.Infrastructure.dll”
- C:\Windows\Microsoft.NET\assembly\GAC\U MSIL\Microsoft.Management.Infrastructure
static void Main(string [] args)
{
var csession = CimSession.Create("");
csession.TestConnection();
}