Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
Fix failed exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
StrangeRanger committed Mar 27, 2024
1 parent 539cf0b commit a29c211
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ActiveDirectoryQuerier/PowerShell/PSExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,19 @@ public PSOutput Execute(Command psCommand, OutputFormat outputFormat = OutputFor

public async Task<PSOutput> ExecuteAsync(Command command, OutputFormat outputFormat = OutputFormat.Text)
{
_powerShell.Commands.Clear();
AssembleFullCommand(command, outputFormat);
try
{
_powerShell.Commands.Clear();
AssembleFullCommand(command, outputFormat);

PSDataCollection<PSObject> results = await _powerShell.InvokeAsync();
PSDataCollection<PSObject> results = await _powerShell.InvokeAsync();

return ProcessExecutionResults(results);
return ProcessExecutionResults(results);
}
catch (Exception exception)
{
return HandleExecutionException(exception);
}
}

private void AssembleFullCommand(Command psCommand, OutputFormat outputFormat)
Expand Down

0 comments on commit a29c211

Please sign in to comment.