diff --git a/src/PowerShell/PowerShellManager.cs b/src/PowerShell/PowerShellManager.cs index 9e9dd927..c527b67a 100644 --- a/src/PowerShell/PowerShellManager.cs +++ b/src/PowerShell/PowerShellManager.cs @@ -253,6 +253,11 @@ internal Hashtable InvokeFunction( } catch (RuntimeException e) { + if (e.ErrorRecord.FullyQualifiedErrorId == "CommandNotFoundException") + { + _logger.Log(isUserOnlyLog: false, LogLevel.Warning, PowerShellWorkerStrings.CommandNotFoundException_Exception); + } + Logger.Log(isUserOnlyLog: true, LogLevel.Error, GetFunctionExceptionMessage(e)); throw; } diff --git a/src/PowerShell/StreamHandler.cs b/src/PowerShell/StreamHandler.cs index cec15fcf..3da1258d 100644 --- a/src/PowerShell/StreamHandler.cs +++ b/src/PowerShell/StreamHandler.cs @@ -33,6 +33,11 @@ public void ErrorDataAdding(object sender, DataAddingEventArgs e) { if(e.ItemAdded is ErrorRecord record) { + if (record.FullyQualifiedErrorId == "CommandNotFoundException") + { + _logger.Log(isUserOnlyLog: false, LogLevel.Warning, PowerShellWorkerStrings.CommandNotFoundException_Error); + } + _logger.Log(isUserOnlyLog: true, LogLevel.Error, $"ERROR: {_errorRecordFormatter.Format(record)}", record.Exception); } } diff --git a/src/resources/PowerShellWorkerStrings.resx b/src/resources/PowerShellWorkerStrings.resx index 29d82432..a17b6623 100644 --- a/src/resources/PowerShellWorkerStrings.resx +++ b/src/resources/PowerShellWorkerStrings.resx @@ -298,4 +298,10 @@ Failed to enumerate dependency snapshot '{0}' content: {1} + + CommandNotFoundException detected (error). + + + CommandNotFoundException detected (exception). + \ No newline at end of file