protected override void ProcessRecord() { ConnectionGenerator generator = new ConnectionGenerator(UseSSL, Credential, Port); Runspace R = generator.Generate(ComputerName, Timeout); R.Open(); PowerShell shell = PowerShell.Create(); shell.Runspace = R; string script = Host.UI.ReadLine(); while (!script.Equals("exit", StringComparison.CurrentCultureIgnoreCase)) { shell.Commands.Clear(); shell.AddScript(script); Collection<PSObject> ret = shell.Invoke(); if (ret != null) WriteObject(ret, true); Host.UI.WriteLine(); Host.UI.Write(ComputerName + "> "); script = Host.UI.ReadLine(); } try { shell.Dispose(); R.Close(); } catch (Exception) { } }
protected override void ProcessRecord() { ConnectionGenerator generator = new ConnectionGenerator(UseSSL, Credential, Port); foreach (string comp in ComputerName) { Collection<PSObject> result = Exec(generator.Generate(comp, Timeout), this.Command); RemoteOutput O = new RemoteOutput(comp); if (result != null) O.Output.AddRange(result); else O.Output = null; WriteObject(O); } }