From 0e48114c7a3ebb220b616491360e6528ff8d78e1 Mon Sep 17 00:00:00 2001 From: Yeming Liu <11371776+isra-fel@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:18:45 +0800 Subject: [PATCH] Fix unexpected recommendation message --- src/Accounts/Accounts/ChangeLog.md | 1 + src/Accounts/Accounts/Utilities/CommandNotFoundHelper.cs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Accounts/Accounts/ChangeLog.md b/src/Accounts/Accounts/ChangeLog.md index 0afc8a0b674d..1b123d123087 100644 --- a/src/Accounts/Accounts/ChangeLog.md +++ b/src/Accounts/Accounts/ChangeLog.md @@ -19,6 +19,7 @@ --> ## Upcoming Release +* Fixed an issue that the helper message about missing modules shows up at the wrong time. [#19228] ## Version 2.11.2 * Supported Web Account Manager on ARM64-based Windows systems. Fixed an issue where `Connect-AzAccount` failed with error "Unable to load DLL 'msalruntime_arm64'". [#20700] diff --git a/src/Accounts/Accounts/Utilities/CommandNotFoundHelper.cs b/src/Accounts/Accounts/Utilities/CommandNotFoundHelper.cs index e7a7009802d1..c05d858585fe 100644 --- a/src/Accounts/Accounts/Utilities/CommandNotFoundHelper.cs +++ b/src/Accounts/Accounts/Utilities/CommandNotFoundHelper.cs @@ -131,7 +131,9 @@ public static void RegisterCommandNotFoundAction(CommandInvocationIntrinsics cii private static void OnCommandNotFound(object sender, CommandLookupEventArgs args) { - if (IsAzOrAzureRMCmdlet(args.CommandName)) + // The command was dispatched by the msh engine as a result of a dispatch request from an already running command. + // We are not interested in such cases. + if (args.CommandOrigin == CommandOrigin.Runspace && IsAzOrAzureRMCmdlet(args.CommandName)) { bool isHelpful = true; if (IsAzureRMCommand(args.CommandName))