diff --git a/PowerShellBlazor/Services/PowerShellService.cs b/PowerShellBlazor/Services/PowerShellService.cs
index 9ae9063..271ab46 100644
--- a/PowerShellBlazor/Services/PowerShellService.cs
+++ b/PowerShellBlazor/Services/PowerShellService.cs
@@ -49,12 +49,7 @@ namespace PowerShellBlazor.Services
PowerShell shell = PowerShell.Create();
shell.AddCommand(pscommand);
- string fontstr = "";
-
AddOutput(PSStream.Output, "Executing: " + shell.Commands.Commands[0].ToString());
- string prevmsg = "";
- string msg = "";
-
AddOutput(PSStream.Output, "BEGIN");
AddOutput(PSStream.Output, "_________________________________________________________________________");
@@ -83,122 +78,6 @@ namespace PowerShellBlazor.Services
shell.Streams.Error.DataAdded += delegate (object? sender, DataAddedEventArgs e)
{
AddOutput(PSStream.Error, shell.Streams.Error[e.Index].ToString());
-=======
- public List Output { get; set; } = new();
-
- private void AddOutput(string str)
- {
- Output.Add(str);
- OutputChanged.Invoke(this, Output);
- }
-
- public event EventHandler> OutputChanged;
-
- public async Task RunScript(PowerShell shell, bool varwidth)
- {
- if (shell == null)
- {
- AddOutput("Shell empty - nothing to execute");
- }
- else
- {
- string fontstr = "";
- if (varwidth != true)
- {
- fontstr = "face='monospace' size=3";
- }
-
- AddOutput("Executing: " + shell.Commands.Commands[0].ToString());
- string prevmsg = "";
- string msg = "";
-
- AddOutput("
BEGIN");
- AddOutput("
_________________________________________________________________________");
-
- var psOutput = new PSDataCollection();
-
- // Collect powershell OUTPUT
- psOutput.DataAdded += delegate (object? sender, DataAddedEventArgs e)
- {
- msg = psOutput[e.Index].ToString();
-
- if (msg != prevmsg)
- {
- AddOutput("
" + msg + "");
- }
- else
- {
- AddOutput(".");
- }
- prevmsg = msg;
- if (sender is not null)
- {
- var psoutput = (PSDataCollection)sender;
- Collection results = psoutput.ReadAll();
- }
- };
-
- prevmsg = "";
- // Collect powershell PROGRESS output
- shell.Streams.Progress.DataAdded += delegate (object? sender, DataAddedEventArgs e)
- {
- msg = shell.Streams.Progress[e.Index].Activity.ToString();
- if (msg != prevmsg)
- {
- AddOutput("
" + msg + "");
- }
- else
- {
- AddOutput(".");
- }
- prevmsg = msg;
- if (sender is not null)
- {
- var psprogress = (PSDataCollection)sender;
- Collection results = psprogress.ReadAll();
- }
- };
-
- prevmsg = "";
- // Collect powershell WARNING output
- shell.Streams.Warning.DataAdded += delegate (object? sender, DataAddedEventArgs e)
- {
- msg = shell.Streams.Warning[e.Index].ToString();
- if (msg != prevmsg)
- {
- AddOutput("
***WARNING***: " + msg + "");
- }
- else
- {
- AddOutput(".");
- }
- prevmsg = msg;
- if (sender is not null)
- {
- var pswarning = (PSDataCollection)sender;
- Collection results = pswarning.ReadAll();
- }
- };
-
- prevmsg = "";
- // Collect powershell ERROR output
- shell.Streams.Error.DataAdded += delegate (object? sender, DataAddedEventArgs e)
- {
- msg = shell.Streams.Error[e.Index].ToString();
- if (msg != prevmsg)
- {
- AddOutput("
***ERROR***: " + msg + "");
- }
- else
- {
- AddOutput(".");
- }
- prevmsg = msg;
- if (sender is not null)
- {
- var pserror = (PSDataCollection)sender;
- Collection results = pserror.ReadAll();
- }
};
// Execute powershell command