From c12b82dc80b1edd2777519dbcc59e06ae192df88 Mon Sep 17 00:00:00 2001 From: Andrew Menagarishvili Date: Mon, 25 Nov 2019 14:07:23 -0800 Subject: [PATCH] Disable AutoloadModulesWithJobSourceAdapters --- .../engine/CommandDiscovery.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/CommandDiscovery.cs b/src/System.Management.Automation/engine/CommandDiscovery.cs index d5c639430cf..9410c9e58f5 100644 --- a/src/System.Management.Automation/engine/CommandDiscovery.cs +++ b/src/System.Management.Automation/engine/CommandDiscovery.cs @@ -884,6 +884,11 @@ internal static CommandInfo LookupCommandInfo( internal static void AutoloadModulesWithJobSourceAdapters(System.Management.Automation.ExecutionContext context, CommandOrigin commandOrigin) { + /* This function is used by *-Job cmdlets (JobCmdletBase.BeginProcessing(), StartJobCommand.BeginProcessing()) + It attempts to load modules from a fixed ModulesWithJobSourceAdapters list that currently has only `PSScheduledJob` module that is not PS-Core compatible. + Because this function does not check the result of a (currently failing) `PSScheduledJob` module autoload, it provides no value. + After discussion it was decided to comment out this code as it may be useful if ModulesWithJobSourceAdapters list changes in the future. + if (!context.IsModuleWithJobSourceAdapterLoaded) { PSModuleAutoLoadingPreference moduleAutoLoadingPreference = GetCommandDiscoveryPreference(context, SpecialVariables.PSModuleAutoLoadingPreferenceVarPath, "PSModuleAutoLoadingPreference"); @@ -906,7 +911,7 @@ internal static void AutoloadModulesWithJobSourceAdapters(System.Management.Auto context.IsModuleWithJobSourceAdapterLoaded = true; } } - } + }*/ } internal static Collection AutoloadSpecifiedModule(string moduleName, ExecutionContext context, SessionStateEntryVisibility visibility, out Exception exception)