#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public PSInvocationResult(string script, IPSInvocationContext context, PowerShell powerShell, object[] variableKeys, params object[] arguments) #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member { ErrorRecord error = null; try { if (context.UseLocalScope.HasValue) { powerShell.AddScript(script, context.UseLocalScope.Value); } else { powerShell.AddScript(script); } if (arguments != null && arguments.Length > 0) { foreach (object a in arguments) { powerShell.AddArgument(a); } } _output = powerShell.Invoke(); #if !PSLEGACY _hadErrors = powerShell.HadErrors; #endif _ranToCompletion = true; } catch (RuntimeException exception) { error = exception.ErrorRecord; _hadErrors = true; } catch (ArgumentException exception) { error = new ErrorRecord(exception, "UnexpectedInvalidArgument", ErrorCategory.InvalidArgument, script); _hadErrors = true; } catch (Exception exception) { error = new ErrorRecord(exception, "UnexpectedError", ErrorCategory.NotSpecified, script); _hadErrors = true; } _errors = powerShell.Streams.Error.ReadAll(); if (error != null) { _errors.Add(error); } #if PSLEGACY if (_errors.Count > 0) { _hadErrors = true; } #endif _warnings = powerShell.Streams.Warning.ReadAll(); _verbose = powerShell.Streams.Verbose.ReadAll(); _debug = powerShell.Streams.Debug.ReadAll(); if (_output == null) { _output = new Collection <PSObject>(); } _variables = new Hashtable(); foreach (object key in variableKeys) { _variables[key] = powerShell.Runspace.SessionStateProxy.GetVariable((key is string) ? key as string : key.ToString()); } }
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public PSInvocationResult(string script, IPSInvocationContext context, PowerShell powerShell, object[] variableKeys) : this(script, context, powerShell, variableKeys, new object[0]) { }