[英]Why can't i return all cimsession functions from Powershell.Invoke() method in c#
I'm running New-CimSession
command from both Powershell and C#.我正在从 Powershell 和 C# 运行New-CimSession
命令。 When I run it on Powershell, CimSession variable has a lot of functions such as TestConnection()
, CreateInstance
etc.. Picture is below.当我在 Powershell 上运行它时,CimSession 变量有很多功能,例如TestConnection()
、 CreateInstance
等。图片如下。
But, CimSession
variable type of PSObject
doesn't have others functions except ToString()
and GetType()
, when I run New-CimSession
command from Powershell.Invoke()
method in c#.但是, CimSession
的变量类型PSObject
没有其他功能除了ToString()
和GetType()
当我运行New-CimSession
从命令Powershell.Invoke()
方法在C#。
I want to access same method from PSObject
variable on c#.我想从 c# 上的PSObject
变量访问相同的方法。 Do you have a idea?你有什么想法吗?
Microsoft.Management.Infrastructure Namespace
添加对Microsoft.Management.Infrastructure Namespace
引用static void Main(string [] args)
{
var csession = CimSession.Create("");
csession.TestConnection();
}
csession
will have access to different Methods you want csession
将可以访问您想要的不同方法
Reference here:参考这里:
"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\WMI\\v1.0\\Microsoft.Management.Infrastructure.dll" “C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\WMI\\v1.0\\Microsoft.Management.Infrastructure.dll”
C:\\Windows\\Microsoft.NET\\assembly\\GAC_MSIL\\Microsoft.Management.Infrastructure C:\\Windows\\Microsoft.NET\\assembly\\GAC_MSIL\\Microsoft.Management.Infrastructure
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.