Closed theGeorgew closed 1 year ago
We'll just have to override $ErrorActionPreference
during this code path.
Ok so this is the code we're using to import that module:
PSCommand psCommand = new PSCommand()
.AddCommand("Import-Module")
.AddArgument(@"C:\Program Files\DesiredStateConfiguration\1.0.0.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psd1")
.AddParameter("PassThru");
IReadOnlyList<PSModuleInfo> dscModule =
await psesHost.ExecutePSCommandAsync<PSModuleInfo>(
psCommand,
CancellationToken.None,
new PowerShellExecutionOptions { ThrowOnError = false }).ConfigureAwait(false);
isDscInstalled = dscModule.Count > 0;
logger.LogDebug("Side-by-side DSC module found: " + isDscInstalled.Value);
I'm testing some stuff...strangely I can get the error to show up, but I can't repro where it causes things to crash, even with '$ErrorActionPreference = "stop"
.
Prerequisites
Steps to reproduce
Set the profile's EAP to stop Set-content -path $pshome/profile.ps1 -value '$ErrorActionPreference = "stop"' Debug a Powershell script that has a breakpoint set Observe the Powershell terminal prints an error importing the DSC module. The script will also not stop at the breakpoint.
if you rollback the version of the Powershell Extension to the previous release the error does not occur code --install-extension powershell-2023.5.0.vsix --force I saw that this issue was merged for the release that is causing the bug: https://github.com/PowerShell/PowerShellEditorServices/pull/2020 I see there were changes made to the loading of the DSC module that is failing to be loaded in the error https://github.com/PowerShell/PowerShellEditorServices/pull/2020/files#diff-df2c1977dd89746b4b394dc2e26725467d330545813bf2bbc3383476693de476R94-R97
Expected behavior
Actual behavior
Error details
Environment data
Version
2023.6.0
Visuals
No response