Tag: powershell remoting

使用Powershell RunspacePool从C#multithreading到远程服务器

我正在尝试使用Powershell RunspacePool创建一些C#代码到远程服务器。 当maxRunspaces设置为1时,一切正常,但将其设置为2会带来麻烦。 var connectionInfo = new WSManConnectionInfo(target, shellUri, credential); using (RunspacePool pool = RunspaceFactory.CreateRunspacePool(1, 2, connectionInfo)) { pool.ApartmentState = System.Threading.ApartmentState.STA; pool.ThreadOptions = PSThreadOptions.UseNewThread; pool.Open(); var tasks = new List(); for (var i = 0; i < 12; i++) { var taskID = i; var ps = PowerShell.Create(); ps.RunspacePool = pool; ps.AddCommand("Get-NAVServerInstance"); var task = […]

如何托管Powershell脚本或应用程序,以便可以通过WSManConnectionInfo访问它? (如Office 365)

我知道连接到远程运行空间的唯一方法包括以下参数 WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, “localhost”, 80, “/Powershell”, “http://schemas.microsoft.com/powershell/Microsoft.Exchange”, credential); 要么 WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, “localhost”, 5985, “/wsman”, “http://schemas.microsoft.com/powershell/Microsoft.Powershell”, credential); 如何设置我自己的自定义Powershell对象,以便通过HTTP公开它? 使用的正确参数是什么以及如何设置它们?