}// CreateHelpersForSpecifiedContainerSession /// <summary> /// Creates a pipeline from the powershell /// </summary> /// <param name="remoteRunspace">runspace on which to create the pipeline</param> /// <returns>a pipeline</returns> internal Pipeline CreatePipeline(RemoteRunspace remoteRunspace) { // The fix to WinBlue#475223 changed how UsingExpression is handled on the client/server sides, if the remote end is PSv5 // or later, we send the dictionary-form using values to the remote end. If the remote end is PSv3 or PSv4, then we send // the array-form using values if all UsingExpressions are in the same scope, otherwise, we handle the UsingExpression as // if the remote end is PSv2. string serverPsVersion = GetRemoteServerPsVersion(remoteRunspace); System.Management.Automation.PowerShell powershellToUse = (serverPsVersion == PSv2) ? GetPowerShellForPSv2() : GetPowerShellForPSv3OrLater(serverPsVersion); Pipeline pipeline = remoteRunspace.CreatePipeline(powershellToUse.Commands.Commands[0].CommandText, true); pipeline.Commands.Clear(); foreach (Command command in powershellToUse.Commands.Commands) { pipeline.Commands.Add(command); } pipeline.RedirectShellErrorOutputPipe = true; return pipeline; }
internal Pipeline CreatePipeline(RemoteRunspace remoteRunspace) { PowerShell shell = remoteRunspace.GetCapabilities().Equals(RunspaceCapability.Default) ? this.GetPowerShellForPSv2() : this.GetPowerShellForPSv3(); Pipeline pipeline = remoteRunspace.CreatePipeline(shell.Commands.Commands[0].CommandText, true); pipeline.Commands.Clear(); foreach (Command command in shell.Commands.Commands) { pipeline.Commands.Add(command); } pipeline.RedirectShellErrorOutputPipe = true; return pipeline; }