Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert-Module issue with backwards compatibility #131

Closed
mgreenegit opened this issue Oct 10, 2024 · 1 comment · Fixed by #132
Closed

Assert-Module issue with backwards compatibility #131

mgreenegit opened this issue Oct 10, 2024 · 1 comment · Fixed by #132
Labels
enhancement The issue is an enhancement request. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub

Comments

@mgreenegit
Copy link

Problem description

In Assert-Module, there is a check to see if a module is available and if not, throw an exception. I've run into an issue trying to run community resources in Pwsh 7.x, when the resource is using assert-module to verify a PowerShell module that is expected to be available in Windows PowerShell 5.1. The workaround looks to be -skipeditioncheck, but we would need to test to see if that breaks any other part of the workflow for dscresource.common.

Reference:

if (-not (Get-Module -Name $ModuleName -ListAvailable))

To see the difference, try running these examples in Pwsh 7.x.
$p = Get-Module -listavailable
$p.count

$s = Get-Module -listavailable -skipeditioncheck
$s.count

Verbose logs

NA

How to reproduce

$p = Get-Module -listavailable
$p.count

$s = Get-Module -listavailable -skipeditioncheck
$s.count

Expected behavior

Assert-Module should identify modules from Windows PowerShell 5.1 even when hosted in Pwsh 7.x, due to implicit remoting.

Current behavior

Implicit remoting is not invoked. Normally it would happen at import, but the import is not called because Get-Module -listavailable does not find it, so Assert-Module throws an exception.

Suggested solution

Test with -skipeditioncheck to verify whether it resolves the issue or if any regressions are created.

Operating system the target node is running

NA

PowerShell version and build the target node is running

7.x

Module version used

NA
@johlju
Copy link
Member

johlju commented Oct 11, 2024

The parameter SkipEditionCheck does not exist in 5.1, but if we only pass parameter SkipEditionCheck when Assert-Module is not run in Windows PowerShell then it wouldn't break anything I think.

@johlju johlju added enhancement The issue is an enhancement request. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub help wanted The issue is up for grabs for anyone in the community. labels Oct 11, 2024
@johlju johlju removed the help wanted The issue is up for grabs for anyone in the community. label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants