
我对PS很陌生,所以我想我在这里错过了一些基本的东西。 我可以做这样的远程PowerShell会话…
$Session = New-PSSession -Configurationname Microsoft.Exchange -ConnectionUri https://remote.com/Powershell -Credential "Domainadmin"
我想在C#中的等价物,所以我想这个,但它不工作…
WSManConnectionInfo connInfo = new WSManConnectionInfo( new Uri("https://remote.com/Powershell"),/* uri */ "/wtf",/* shellUri??? */ cred); /* ps-credential */ using (Runspace runspace = RunspaceFactory.CreateRunspace(connInfo)) { runspace.open(); using (PowerShell ps = PowerShell.Create()) { ps.Runspace = runspace; } }
这失败了…
System.Management.automation.Remoting.PSRemotingTransportException was unhandled Message=Connecting to Remote Server Failed with the following error message : The WS-Management service cannot process the request. The resource URI (/wsman) was not found in the WS-Management catalog....
我怎样才能把它转换成C#? 什么是“shellUri”参数,以及如何传达configuration名称(在我的情况下是Microsoft.Exchange)?
如何处理ATLMFC包含文件中的指针截断?
在编译affdex linux示例应用程序时未定义对进程(std :: __ cxx11 :: basic_string …)的引用
使用SFML在屏幕上居中文本
在C ++中的pthread_create错误(类中的pthread)
以编程方式计算windows上的进程的开始时间
创build一个文件只能在我的应用程序在C + +?
显示可变消息的自定义exception,不同编译器中的不同行为
如何判断一个驱动程序是C ++中的软盘还是可移动的闪存盘?
最低DirectX 9.0c版本以及如何检查它
通过代码,我怎样才能发送硬盘驱动器睡觉
http://schemas.microsoft.com/powershell/Microsoft.Exchange
应该为shell uri工作,并获取上下文到Exchange配置
我使用类似的东西
int iRemotePort = 5985; string strShellURI = @"http://schemas.microsoft.com/powershell/Microsoft.PowerShell"; string strAppname = @"/wsman"; AuthenticationMechanism auth = AuthenticationMechanism.Negotiate; WSManConnectionInfo ci = new WSManConnectionInfo( false,sRemote,iRemotePort,strAppname,strShellURI,creds); ci.AuthenticationMechanism = auth; Runspace runspace = RunspaceFactory.CreateRunspace(ci); runspace.open(); PowerShell psh = PowerShell.Create(); psh.Runspace = runspace;
有了这个你可以访问远程PowerShell会话..使用psh远程运行命令。
shellUri 应该是http://schemas.microsoft.com/powershell/Microsoft.Exchange 。
总结以上是内存溢出为你收集整理的在C#中创build远程PowerShell会话?全部内容,希望文章能够帮你解决在C#中创build远程PowerShell会话?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)