[英]Why can't i return all cimsession functions from Powershell.Invoke() method in c#
我正在從 Powershell 和 C# 運行New-CimSession
命令。 當我在 Powershell 上運行它時,CimSession 變量有很多功能,例如TestConnection()
、 CreateInstance
等。圖片如下。
但是, CimSession
的變量類型PSObject
沒有其他功能除了ToString()
和GetType()
當我運行New-CimSession
從命令Powershell.Invoke()
方法在C#。
我想從 c# 上的PSObject
變量訪問相同的方法。 你有什么想法嗎?
Microsoft.Management.Infrastructure Namespace
引用static void Main(string [] args)
{
var csession = CimSession.Create("");
csession.TestConnection();
}
csession
將可以訪問您想要的不同方法
參考這里:
“C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\WMI\\v1.0\\Microsoft.Management.Infrastructure.dll”
C:\\Windows\\Microsoft.NET\\assembly\\GAC_MSIL\\Microsoft.Management.Infrastructure
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.