本文整理汇总了C#中PSDataCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# PSDataCollection.Add方法的具体用法?C# PSDataCollection.Add怎么用?C# PSDataCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PSDataCollection
的用法示例。
在下文中一共展示了PSDataCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractErrorFromErrorRecord
public static string ExtractErrorFromErrorRecord(this Runspace runspace, ErrorRecord record)
{
Pipeline pipeline = runspace.CreatePipeline("$input", false);
pipeline.Commands.Add("out-string");
Collection<PSObject> result;
using (PSDataCollection<object> inputCollection = new PSDataCollection<object>())
{
inputCollection.Add(record);
inputCollection.Complete();
result = pipeline.Invoke(inputCollection);
}
if (result.Count > 0)
{
string str = result[0].BaseObject as string;
if (!string.IsNullOrEmpty(str))
{
// Remove \r\n, which is added by the Out-String cmdlet.
return str.Substring(0, str.Length - 2);
}
}
return String.Empty;
}
示例2: BeginInvoke
/// <summary>
/// Starts the pipeline script async.
/// </summary>
public void BeginInvoke(Queue<PSObject> queue, int count)
{
var input = new PSDataCollection<PSObject>(count);
while (--count >= 0)
input.Add(queue.Dequeue());
input.Complete();
_async = _posh.BeginInvoke(input);
}
示例3: ReportException
private void ReportException(Exception e)
{
if (e != null)
{
object error;
IContainsErrorRecord icer = e as IContainsErrorRecord;
if (icer != null)
{
error = icer.ErrorRecord;
}
else
{
error = (object)new ErrorRecord(e, "Host.ReportException", ErrorCategory.NotSpecified, null);
}
lock (this.instanceLock)
{
this.currentPowerShell = PowerShell.Create();
}
this.currentPowerShell.Runspace = this.myRunSpace;
try
{
this.currentPowerShell.AddScript("$input").AddCommand("out-string");
Collection<PSObject> result;
PSDataCollection<object> inputCollection = new PSDataCollection<object>();
inputCollection.Add(error);
inputCollection.Complete();
result = this.currentPowerShell.Invoke(inputCollection);
if (result.Count > 0)
{
string str = result[0].BaseObject as string;
if (!string.IsNullOrEmpty(str))
{
this.myHost.UI.WriteErrorLine(str.Substring(0, str.Length - 2));
}
}
}
finally
{
lock (this.instanceLock)
{
this.currentPowerShell.Dispose();
this.currentPowerShell = null;
}
}
}
}
示例4: SortStartParameters
/// <summary>
/// Create necessary dictionaries for WorkflowManager consumption based on StartParameters.
/// </summary>
private void SortStartParameters(DynamicActivity dynamicActivity, CommandParameterCollection parameters)
{
bool selfRemoting = dynamicActivity != null && dynamicActivity.Properties.Any(x => x.Name.Equals(Constants.ComputerName, StringComparison.CurrentCultureIgnoreCase));
bool takesPSPrivateMetadata = dynamicActivity != null && dynamicActivity.Properties.Contains(Constants.PrivateMetadata);
_jobMetadata.Add(Constants.WorkflowTakesPrivateMetadata, takesPSPrivateMetadata);
if (parameters != null)
{
foreach (var parameter in parameters)
{
_tracer.WriteMessage(ClassNameTrace, "SortStartParameters", WorkflowGuidForTraces, this, "Found parameter; {0}; {1}", parameter.Name,
parameter.Value == null ? null : parameter.Value.ToString());
switch (parameter.Name)
{
case Constants.ComputerName:
if (selfRemoting)
{
// If we're self-remoting, location becomes the default computer
// and the PSComputerNames is passed in as an argument instead
// of going to the ubiquitous parameters
_location = Constants.DefaultComputerName;
string parameterName = dynamicActivity.Properties.First(x => x.Name.Equals(Constants.ComputerName, StringComparison.CurrentCultureIgnoreCase)).Name;
_workflowParameters[parameterName] = LanguagePrimitives.ConvertTo<string[]>(parameter.Value);
}
else
{
// Set _location before adding parameter.
var computer = parameter.Value as string;
_location = computer;
string[] computerNames = LanguagePrimitives.ConvertTo<string[]>(parameter.Value);
_psWorkflowCommonParameters[parameter.Name] = computerNames;
}
break;
case Constants.PrivateMetadata:
Hashtable privateData = parameter.Value as Hashtable;
if (privateData != null)
{
IDictionaryEnumerator enumerator = privateData.GetEnumerator();
while (enumerator.MoveNext())
{
_privateMetadata.Add(enumerator.Key.ToString(), enumerator.Value);
}
// Make the combined object available within the workflow as well...
if (takesPSPrivateMetadata)
{
_workflowParameters.Add(parameter.Name, parameter.Value);
}
}
break;
case Constants.PSInputCollection:
{
// Remove the input collection so we can properly pass it to the workflow job
object baseObject = parameter.Value is PSObject
? ((PSObject)parameter.Value).BaseObject
: parameter.Value;
if (baseObject is PSDataCollection<PSObject>)
{
_inputCollection = baseObject as PSDataCollection<PSObject>;
}
else
{
var inputCollection = new PSDataCollection<PSObject>();
var e = LanguagePrimitives.GetEnumerator(baseObject);
if (e != null)
{
while (e.MoveNext())
{
inputCollection.Add(PSObject.AsPSObject(e.Current));
}
}
else
{
inputCollection.Add(PSObject.AsPSObject(parameter.Value));
}
_inputCollection = inputCollection;
}
}
break;
case Constants.PSParameterCollection:
// Remove this one from the parameter collection...
break;
case Constants.PSRunningTime:
case Constants.PSElapsedTime:
case Constants.ConnectionRetryCount:
case Constants.ActionRetryCount:
case Constants.ConnectionRetryIntervalSec:
case Constants.ActionRetryIntervalSec:
_psWorkflowCommonParameters.Add(parameter.Name, parameter.Value);
break;
case Constants.Persist:
case Constants.Credential:
case Constants.Port:
//.........这里部分代码省略.........
示例5: OnData
private void OnData(object sender, NotifyCollectionChangedEventArgs e)
{
if( e.Action != NotifyCollectionChangedAction.Add)
{
return;
}
PSDataCollection<object> input = new PSDataCollection<object>();
foreach (var ci in e.NewItems)
{
input.Add(ci);
}
Interlocked.Exchange( ref _currentInput, input );
RaiseTrigger();
}
示例6: ContinueCommand
internal static void ContinueCommand(RemoteRunspace remoteRunspace, Pipeline cmd, PSHost host, bool inDebugMode, System.Management.Automation.ExecutionContext context)
{
RemotePipeline remotePipeline = cmd as RemotePipeline;
if (remotePipeline != null)
{
using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create())
{
PSInvocationSettings settings = new PSInvocationSettings()
{
Host = host
};
PSDataCollection<PSObject> input = new PSDataCollection<PSObject>();
CommandInfo commandInfo = new CmdletInfo("Out-Default", typeof(OutDefaultCommand), null, null, context);
Command outDefaultCommand = new Command(commandInfo);
ps.AddCommand(outDefaultCommand);
IAsyncResult async = ps.BeginInvoke<PSObject>(input, settings, null, null);
RemoteDebugger remoteDebugger = remoteRunspace.Debugger as RemoteDebugger;
if (remoteDebugger != null)
{
// Update client with breakpoint information from pushed runspace.
// Information will be passed to the client via the Debugger.BreakpointUpdated event.
remoteDebugger.SendBreakpointUpdatedEvents();
if (!inDebugMode)
{
// Enter debug mode if remote runspace is in debug stop mode.
remoteDebugger.CheckStateAndRaiseStopEvent();
}
}
// Wait for debugged cmd to complete.
while (!remotePipeline.Output.EndOfPipeline)
{
remotePipeline.Output.WaitHandle.WaitOne();
while (remotePipeline.Output.Count > 0)
{
input.Add(remotePipeline.Output.Read());
}
}
input.Complete();
ps.EndInvoke(async);
}
}
}
示例7: ValidateAndThrowRunspaceOpenModuleLoadException
private void ValidateAndThrowRunspaceOpenModuleLoadException(PowerShell pse, List<ErrorRecord> errors, bool startLifeCycleEventWritten, string moduleName, RunspaceOpenModuleLoadException exception)
{
if (this.InitialSessionState.ThrowOnRunspaceOpenError)
{
RunspaceOpenModuleLoadException exception2 = null;
if (exception != null)
{
exception2 = exception;
}
else if ((pse.Streams.Error.Count > 0) || (errors.Count > 0))
{
ErrorRecord record;
Exception exception3;
PSDataCollection<ErrorRecord> datas = new PSDataCollection<ErrorRecord>();
if (errors.Count > 0)
{
record = errors[0];
exception3 = record.Exception;
foreach (ErrorRecord record2 in errors)
{
datas.Add(record2);
}
}
else
{
record = pse.Streams.Error[0];
exception3 = record.Exception;
foreach (ErrorRecord record3 in pse.Streams.Error)
{
datas.Add(record3);
}
}
runspaceInitTracer.WriteLine("Runspace open failed while loading module '{0}': First error {1}", new object[] { moduleName, exception3 });
exception2 = new RunspaceOpenModuleLoadException(moduleName, datas);
}
if (exception2 != null)
{
this.LogEngineHealthEvent(exception2);
if (startLifeCycleEventWritten)
{
MshLog.LogEngineLifecycleEvent(this._engine.Context, EngineState.Stopped);
}
base.SetRunspaceState(RunspaceState.Broken, exception2);
base.RaiseRunspaceStateEvents();
throw exception2;
}
}
}
示例8: ProcessCommand
/// <summary>
/// ProcessCommand
/// </summary>
/// <param name="command">PowerShell command</param>
/// <param name="output">Output</param>
/// <returns>DebuggerCommandResults</returns>
public override DebuggerCommandResults ProcessCommand(PSCommand command, PSDataCollection<PSObject> output)
{
if (command == null)
{
throw new PSArgumentNullException("command");
}
if (output == null)
{
throw new PSArgumentNullException("output");
}
if (!DebuggerStopped)
{
throw new PSInvalidOperationException(
DebuggerStrings.CannotProcessDebuggerCommandNotStopped,
null,
Debugger.CannotProcessCommandNotStopped,
ErrorCategory.InvalidOperation,
null);
}
//
// Allow an active pushed debugger to process commands
//
DebuggerCommandResults results = ProcessCommandForActiveDebugger(command, output);
if (results != null)
{
return results;
}
//
// Otherwise let root script debugger handle it.
//
LocalRunspace localRunspace = _context.CurrentRunspace as LocalRunspace;
if (localRunspace == null)
{
throw new PSInvalidOperationException(
DebuggerStrings.CannotProcessDebuggerCommandNotStopped,
null,
Debugger.CannotProcessCommandNotStopped,
ErrorCategory.InvalidOperation,
null);
}
try
{
using (_psDebuggerCommand = PowerShell.Create())
{
if (localRunspace.GetCurrentlyRunningPipeline() != null)
{
_psDebuggerCommand.SetIsNested(true);
}
_psDebuggerCommand.Runspace = localRunspace;
_psDebuggerCommand.Commands = command;
foreach (var cmd in _psDebuggerCommand.Commands.Commands)
{
cmd.MergeMyResults(PipelineResultTypes.All, PipelineResultTypes.Output);
}
PSDataCollection<PSObject> internalOutput = new PSDataCollection<PSObject>();
internalOutput.DataAdded += (sender, args) =>
{
foreach (var item in internalOutput.ReadAll())
{
if (item == null) { continue; }
DebuggerCommand dbgCmd = item.BaseObject as DebuggerCommand;
if (dbgCmd != null)
{
bool executedByDebugger = (dbgCmd.ResumeAction != null || dbgCmd.ExecutedByDebugger);
results = new DebuggerCommandResults(dbgCmd.ResumeAction, executedByDebugger);
}
else
{
output.Add(item);
}
}
};
// Allow any exceptions to propagate.
_psDebuggerCommand.InvokeWithDebugger(null, internalOutput, null, false);
}
}
finally
{
_psDebuggerCommand = null;
}
return results ?? new DebuggerCommandResults(null, false);
}
示例9: InvokePowerShellScript
private async Task<PSDataCollection<ErrorRecord>> InvokePowerShellScript(Dictionary<string, string> envVars, TraceWriter traceWriter)
{
InitialSessionState iss = InitialSessionState.CreateDefault();
PSDataCollection<ErrorRecord> errors = new PSDataCollection<ErrorRecord>();
using (Runspace runspace = RunspaceFactory.CreateRunspace(iss))
{
runspace.Open();
SetRunspaceEnvironmentVariables(runspace, envVars);
RunspaceInvoke runSpaceInvoker = new RunspaceInvoke(runspace);
runSpaceInvoker.Invoke("Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted");
using (
System.Management.Automation.PowerShell powerShellInstance =
System.Management.Automation.PowerShell.Create())
{
powerShellInstance.Runspace = runspace;
_moduleFiles = GetModuleFilePaths(_host.ScriptConfig.RootScriptPath, _functionName);
if (_moduleFiles.Any())
{
powerShellInstance.AddCommand("Import-Module").AddArgument(_moduleFiles);
LogLoadedModules();
}
_script = GetScript(_scriptFilePath);
powerShellInstance.AddScript(_script, true);
PSDataCollection<PSObject> outputCollection = new PSDataCollection<PSObject>();
outputCollection.DataAdded += (sender, e) => OutputCollectionDataAdded(sender, e, traceWriter);
powerShellInstance.Streams.Error.DataAdded += (sender, e) => ErrorDataAdded(sender, e, traceWriter);
IAsyncResult result = powerShellInstance.BeginInvoke<PSObject, PSObject>(null, outputCollection);
await Task.Factory.FromAsync<PSDataCollection<PSObject>>(result, powerShellInstance.EndInvoke);
foreach (ErrorRecord errorRecord in powerShellInstance.Streams.Error)
{
errors.Add(errorRecord);
}
}
runspace.Close();
}
return errors;
}
示例10: ProcessCommand
/// <summary>
/// Process debugger command.
/// </summary>
/// <param name="command">Debugger PSCommand</param>
/// <param name="output">Output</param>
/// <returns>DebuggerCommandResults</returns>
public override DebuggerCommandResults ProcessCommand(PSCommand command, PSDataCollection<PSObject> output)
{
CheckForValidateState();
_detachCommand = false;
if (command == null)
{
throw new PSArgumentNullException("command");
}
if (output == null)
{
throw new PSArgumentNullException("output");
}
if (!DebuggerStopped)
{
throw new PSInvalidOperationException(
DebuggerStrings.CannotProcessDebuggerCommandNotStopped,
null,
Debugger.CannotProcessCommandNotStopped,
ErrorCategory.InvalidOperation,
null);
}
DebuggerCommandResults results = null;
// Execute command on server.
bool executionError = false;
using (_psDebuggerCommand = GetNestedPowerShell())
{
foreach (var cmd in command.Commands)
{
cmd.MergeMyResults(PipelineResultTypes.All, PipelineResultTypes.Output);
_psDebuggerCommand.AddCommand(cmd);
}
PSDataCollection<PSObject> internalOutput = new PSDataCollection<PSObject>();
internalOutput.DataAdded += (sender, args) =>
{
foreach (var item in internalOutput.ReadAll())
{
if (item == null) { return; }
DebuggerCommand dbgCmd = item.BaseObject as DebuggerCommand;
if (dbgCmd != null)
{
bool executedByDebugger = (dbgCmd.ResumeAction != null || dbgCmd.ExecutedByDebugger);
results = new DebuggerCommandResults(dbgCmd.ResumeAction, executedByDebugger);
}
else if (item.BaseObject is DebuggerCommandResults)
{
results = item.BaseObject as DebuggerCommandResults;
}
else
{
output.Add(item);
}
}
};
try
{
_psDebuggerCommand.Invoke(null, internalOutput, null);
}
catch (Exception e)
{
CommandProcessor.CheckForSevereException(e);
executionError = true;
RemoteException re = e as RemoteException;
if ((re != null) && (re.ErrorRecord != null))
{
// Allow the IncompleteParseException to throw so that the console
// can handle here strings and continued parsing.
if (re.ErrorRecord.CategoryInfo.Reason == typeof(IncompleteParseException).Name)
{
throw new IncompleteParseException(
(re.ErrorRecord.Exception != null) ? re.ErrorRecord.Exception.Message : null,
re.ErrorRecord.FullyQualifiedErrorId);
}
// Allow the RemoteException and InvalidRunspacePoolStateException to propagate so that the host can
// clean up the debug session.
if ((re.ErrorRecord.CategoryInfo.Reason == typeof(InvalidRunspacePoolStateException).Name) ||
(re.ErrorRecord.CategoryInfo.Reason == typeof(RemoteException).Name))
{
throw new PSRemotingTransportException(
(re.ErrorRecord.Exception != null) ? re.ErrorRecord.Exception.Message : string.Empty);
}
}
// Allow all PSRemotingTransportException and RemoteException errors to propagate as this
// indicates a broken debug session.
//.........这里部分代码省略.........
示例11: BeginSetVariablesInRemoteRunspace
private static void BeginSetVariablesInRemoteRunspace(RunCommandsArguments args)
{
Runspace runspace = args.ImplementationContext.PowerShellInstance.Runspace;
PSActivityEnvironment pSActivityEnvironment = args.ImplementationContext.PSActivityEnvironment;
PowerShellTraceSource traceSource = PowerShellTraceSourceFactory.GetTraceSource();
using (traceSource)
{
traceSource.WriteMessage("BEGIN BeginSetVariablesInRemoteRunspace");
PowerShell powerShell = PowerShell.Create();
powerShell.Runspace = runspace;
powerShell.AddScript("\r\n Get-Variable -Exclude input | Remove-Variable 2> $Null;$error.Clear();$input | Foreach-Object {$nvp=$_}; foreach($k in $nvp.keys){set-variable -name $k -value $nvp[$k]}\r\n ");
Dictionary<string, object> variablesToSetInRunspace = PSActivity.GetVariablesToSetInRunspace(pSActivityEnvironment);
PSDataCollection<object> objs = new PSDataCollection<object>();
objs.Add(variablesToSetInRunspace);
PSDataCollection<object> objs1 = objs;
objs1.Complete();
args.HelperCommand = powerShell;
args.HelperCommandInput = objs1;
PSActivity.BeginInvokeOnPowershellCommand(powerShell, objs1, null, new AsyncCallback(PSActivity.SetVariablesCallback), args);
traceSource.WriteMessage("END BeginSetVariablesInRemoteRunspace");
}
}
示例12: WriteProgressRecord
protected void WriteProgressRecord(NativeActivityContext context, PSDataCollection<ProgressRecord> progress, string statusDescription, ProgressRecordType type)
{
string displayName;
int num = 0;
if (progress != null)
{
string str = null;
if (this.PSProgressMessage != null)
{
str = this.PSProgressMessage.Get(context);
if (this.PSProgressMessage.Expression != null && string.IsNullOrEmpty(str))
{
return;
}
}
if (str != null)
{
displayName = string.Concat(base.DisplayName, ": ", str);
}
else
{
displayName = base.DisplayName;
if (string.IsNullOrEmpty(displayName))
{
displayName = base.GetType().Name;
}
}
ProgressRecord progressRecord = new ProgressRecord(0, displayName, statusDescription);
progressRecord.RecordType = type;
string str1 = string.Concat(base.Id, ":");
HostParameterDefaults extension = context.GetExtension<HostParameterDefaults>();
if (extension != null)
{
HostSettingCommandMetadata hostCommandMetadata = extension.HostCommandMetadata;
if (hostCommandMetadata != null)
{
object[] commandName = new object[3];
commandName[0] = hostCommandMetadata.CommandName;
commandName[1] = hostCommandMetadata.StartLineNumber;
commandName[2] = hostCommandMetadata.StartColumnNumber;
str1 = string.Concat(str1, string.Format(CultureInfo.CurrentCulture, Resources.ProgressPositionMessage, commandName));
}
}
progressRecord.CurrentOperation = str1;
foreach (PropertyDescriptor property in context.DataContext.GetProperties())
{
if (!string.Equals(property.DisplayName, "PSParentActivityID", StringComparison.OrdinalIgnoreCase))
{
if (!string.Equals(property.DisplayName, "ProgressPreference", StringComparison.OrdinalIgnoreCase))
{
continue;
}
string value = property.GetValue(context.DataContext) as string;
if (string.IsNullOrEmpty(value) || !string.Equals(value, "SilentlyContinue", StringComparison.OrdinalIgnoreCase) && !string.Equals(value, "Ignore", StringComparison.OrdinalIgnoreCase))
{
continue;
}
return;
}
else
{
object obj = property.GetValue(context.DataContext);
if (obj == null || !LanguagePrimitives.TryConvertTo<int>(obj, CultureInfo.InvariantCulture, out num))
{
continue;
}
progressRecord.ParentActivityId = num;
}
}
progress.Add(progressRecord);
return;
}
else
{
return;
}
}
示例13: PowerShellInvocation_ErrorAdding
private static void PowerShellInvocation_ErrorAdding(object sender, DataAddingEventArgs e, HostSettingCommandMetadata commandMetadata, PSDataCollection<PSObject> output)
{
ErrorRecord itemAdded = e.ItemAdded as ErrorRecord;
if (itemAdded != null)
{
if (commandMetadata != null)
{
ScriptPosition scriptPosition = new ScriptPosition(commandMetadata.CommandName, commandMetadata.StartLineNumber, commandMetadata.StartColumnNumber, null);
ScriptPosition scriptPosition1 = new ScriptPosition(commandMetadata.CommandName, commandMetadata.EndLineNumber, commandMetadata.EndColumnNumber, null);
ScriptExtent scriptExtent = new ScriptExtent(scriptPosition, scriptPosition1);
if (itemAdded.InvocationInfo != null)
{
itemAdded.InvocationInfo.DisplayScriptPosition = scriptExtent;
}
}
if (output != null)
{
output.Add(PSObject.AsPSObject(itemAdded));
}
}
}
示例14: HandleCallStack
protected override DebuggerCommandResults HandleCallStack(PSDataCollection<PSObject> output)
{
// First get call stack from wrapped debugger
PSCommand cmd = new PSCommand();
cmd.AddCommand("Get-PSCallStack");
PSDataCollection<PSObject> callStackOutput = new PSDataCollection<PSObject>();
_wrappedDebugger.ProcessCommand(cmd, callStackOutput);
// Next get call stack from parent debugger.
PSDataCollection<CallStackFrame> callStack = _rootDebugger.GetCallStack().ToArray();
// Combine call stack info.
foreach (var item in callStack)
{
callStackOutput.Add(new PSObject(item));
}
// Display call stack info as formatted.
using (PowerShell ps = PowerShell.Create())
{
ps.AddCommand("Out-String").AddParameter("Stream", true);
ps.Invoke(callStackOutput, output);
}
return new DebuggerCommandResults(null, true);
}
示例15: HandlePromptCommand
protected virtual DebuggerCommandResults HandlePromptCommand(PSDataCollection<PSObject> output)
{
// Nested debugged runspace prompt should look like:
// [ComputerName]: [DBG]: [Process:<id>]: [RunspaceName]: PS C:\>
string computerName = (_runspace.ConnectionInfo != null) ? _runspace.ConnectionInfo.ComputerName : null;
string processPartPattern = "{0}[{1}:{2}]:{3}";
string processPart = StringUtil.Format(processPartPattern,
@"""",
DebuggerStrings.NestedRunspaceDebuggerPromptProcessName,
@"$($PID)",
@"""");
string locationPart = @"""PS $($executionContext.SessionState.Path.CurrentLocation)> """;
string promptScript = "'[DBG]: '" + " + " + processPart + " + " + "' [" + CodeGeneration.EscapeSingleQuotedStringContent(_runspace.Name) + "]: '" + " + " + locationPart;
// Get the command prompt from the wrapped debugger.
PSCommand promptCommand = new PSCommand();
promptCommand.AddScript(promptScript);
PSDataCollection<PSObject> promptOutput = new PSDataCollection<PSObject>();
_wrappedDebugger.ProcessCommand(promptCommand, promptOutput);
string promptString = (promptOutput.Count == 1) ? promptOutput[0].BaseObject as string : string.Empty;
var nestedPromptString = new System.Text.StringBuilder();
// For remote runspaces display computer name in prompt.
if (!string.IsNullOrEmpty(computerName))
{
nestedPromptString.Append("[" + computerName + "]:");
}
nestedPromptString.Append(promptString);
// Fix up for non-remote runspaces since the runspace is not in a nested prompt
// but the root runspace is.
if (string.IsNullOrEmpty(computerName))
{
nestedPromptString.Insert(nestedPromptString.Length - 1, ">");
}
output.Add(nestedPromptString.ToString());
return new DebuggerCommandResults(null, true);
}