@@ -337,6 +337,10 @@ Describe 'E2E tests for Repository resource' -Tags 'CI' {
337337Describe ' E2E tests for PSResourceList resource' - Tags ' CI' {
338338 BeforeAll {
339339 SetupDsc
340+
341+ # # The installed modules will not be found in the Windows PowerShell module path because DSC will install them in the PowerShell 7 context.
342+ # # Therefore, when running these tests on Windows PowerShell, we need to invoke PowerShell 7 explicitly
343+ $isOnWindowsPowerShell = $PSVersionTable.PSVersion.Major -lt 6
340344 }
341345
342346 It ' Can Install testmodule99' {
@@ -348,9 +352,14 @@ Describe 'E2E tests for PSResourceList resource' -Tags 'CI' {
348352 $configPath = Join-Path - Path $PSScriptRoot - ChildPath ' configs/psresourcegetlist.install.dsc.yaml'
349353 & $script :dscExe - l trace config set -f $configPath
350354
351- $psresource = Get-PSResource - Name ' testmodule99' - ErrorAction SilentlyContinue - Version ' 0.0.93'
352- $psresource.Name | Should - Be ' testmodule99'
353- $psresource.Version | Should - Be ' 0.0.93'
355+ if ($isOnWindowsPowerShell ) {
356+ $psresource = pwsh - Command " Get-PSResource -Name 'testmodule99' -ErrorAction SilentlyContinue -Version '0.0.93'"
357+ }
358+ else {
359+ $psresource = Get-PSResource - Name ' testmodule99' - ErrorAction SilentlyContinue - Version ' 0.0.93'
360+ }
361+ $psresource.Name | Should - Be ' testmodule99'
362+ $psresource.Version | Should - Be ' 0.0.93'
354363 }
355364
356365 It ' Can Uninstall testmodule99' {
@@ -359,7 +368,13 @@ Describe 'E2E tests for PSResourceList resource' -Tags 'CI' {
359368 $configPath = Join-Path - Path $PSScriptRoot - ChildPath ' configs/psresourcegetlist.uninstall.dsc.yaml'
360369 & $script :dscExe config set -f $configPath
361370
362- $psresource = Get-PSResource - Name ' testmodule99' - ErrorAction SilentlyContinue - Version ' 0.0.93'
371+ if ($isOnWindowsPowerShell ) {
372+ $psresource = pwsh - Command " Get-PSResource -Name 'testmodule99' -ErrorAction SilentlyContinue -Version '0.0.93'"
373+ }
374+ else {
375+ $psresource = Get-PSResource - Name ' testmodule99' - ErrorAction SilentlyContinue - Version ' 0.0.93'
376+ }
377+
363378 $psresource | Should - BeNullOrEmpty
364379 }
365380
@@ -386,7 +401,13 @@ Describe 'E2E tests for PSResourceList resource' -Tags 'CI' {
386401 $configPath = Join-Path - Path $PSScriptRoot - ChildPath ' configs/psresourcegetlist.moddeps.install.dsc.yaml'
387402 & $script :dscExe config set -f $configPath
388403
389- $psresource = Get-PSResource - Name $modulelist - ErrorAction SilentlyContinue
404+ if ($isOnWindowsPowerShell ) {
405+ $psresource = pwsh - Command " Get-PSResource -Name $modulelist -ErrorAction SilentlyContinue"
406+ }
407+ else {
408+ $psresource = Get-PSResource - Name $modulelist - ErrorAction SilentlyContinue
409+ }
410+
390411 $psresource | Should - HaveCount 5
391412 }
392413
@@ -399,7 +420,13 @@ Describe 'E2E tests for PSResourceList resource' -Tags 'CI' {
399420 $configPath = Join-Path - Path $PSScriptRoot - ChildPath ' configs/psresourcegetlist.prerelease.install.dsc.yaml'
400421 & $script :dscExe config set -f $configPath
401422
402- $psresource = Get-PSResource - Name ' testmodule99' - ErrorAction SilentlyContinue
423+ if ($isOnWindowsPowerShell ) {
424+ $psresource = pwsh - Command " Get-PSResource -Name 'testmodule99' -ErrorAction SilentlyContinue"
425+ }
426+ else {
427+ $psresource = Get-PSResource - Name ' testmodule99' - ErrorAction SilentlyContinue
428+ }
429+
403430 $psresource | Should - HaveCount 2
404431
405432 $psresource | ForEach-Object {
@@ -420,7 +447,13 @@ Describe 'E2E tests for PSResourceList resource' -Tags 'CI' {
420447 $configPath = Join-Path - Path $PSScriptRoot - ChildPath ' configs/psresourcegetlist.oneexisting.install.dsc.yaml'
421448 & $script :dscExe config set -f $configPath
422449
423- $psresource = Get-PSResource - Name ' testmodule99' - ErrorAction SilentlyContinue
450+ if ($isOnWindowsPowerShell ) {
451+ $psresource = pwsh - Command " Get-PSResource -Name 'testmodule99' -ErrorAction SilentlyContinue"
452+ }
453+ else {
454+ $psresource = Get-PSResource - Name ' testmodule99' - ErrorAction SilentlyContinue
455+ }
456+
424457 $psresource | Should - HaveCount 2
425458
426459 $psresource | ForEach-Object {
0 commit comments