From 73272905b538ce781edda438877815d83db22fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 15:59:10 +0200 Subject: [PATCH 01/82] Add `Describe` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index fddd7a12ea6..25d02bdc1db 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -280,6 +280,9 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { } } +Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { +} + Describe 'Get-Module -ListAvailable with path' -Tags "CI" { BeforeAll { $moduleName = 'Banana' From f542dbe7941d2176f72a12c4037df537e24c2184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 15:59:29 +0200 Subject: [PATCH 02/82] Add `BeforeAll` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 25d02bdc1db..b9b27dc9a68 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -281,6 +281,9 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { } Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { + BeforeAll { + $psModulePath = ($env:PSModulePath -split ';')[0] + } } Describe 'Get-Module -ListAvailable with path' -Tags "CI" { From b4f6c5c9e954684b45a03fd5bb24d3ed54ebf38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 15:59:39 +0200 Subject: [PATCH 03/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index b9b27dc9a68..1242b0796fd 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -284,6 +284,13 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume BeforeAll { $psModulePath = ($env:PSModulePath -split ';')[0] } + + It 'wrongly returns module information instead of $null or error for missing script module' { + $path = [System.IO.Path]::GetFullPath("$pwd\missing.psm1") + Test-Path $path | Should -BeFalse + Get-Module -ListAvailable -FullyQualifiedName $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + Get-Module -ListAvailable -Name $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + } } Describe 'Get-Module -ListAvailable with path' -Tags "CI" { From a8390fe95601a7fe6440c8a8b4831bbd0925eaea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 15:59:47 +0200 Subject: [PATCH 04/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 1242b0796fd..20916d88d9f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -291,6 +291,13 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume Get-Module -ListAvailable -FullyQualifiedName $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) Get-Module -ListAvailable -Name $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) } + + It 'wrongly returns module information instead of $null or error for missing script module under $env:PSModulePath' { + $path = [System.IO.Path]::GetFullPath("$psModulePath\missing.psm1") + Test-Path $path | Should -BeFalse + Get-Module -ListAvailable -FullyQualifiedName $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + Get-Module -ListAvailable -Name $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + } } Describe 'Get-Module -ListAvailable with path' -Tags "CI" { From 2eaf4399b1c6980e59f4a1e6d772e1f060af91de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 15:59:57 +0200 Subject: [PATCH 05/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 20916d88d9f..c9a23005b88 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -298,6 +298,13 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume Get-Module -ListAvailable -FullyQualifiedName $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) Get-Module -ListAvailable -Name $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) } + + It 'writes error for missing manifest module' { + $path = [System.IO.Path]::GetFullPath("$pwd\missing") + Test-Path $path | Should -BeFalse + { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + } } Describe 'Get-Module -ListAvailable with path' -Tags "CI" { From e946e4d1b0c68add4dd74476728ea615fe2e7ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 16:00:08 +0200 Subject: [PATCH 06/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index c9a23005b88..50ead6d9802 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -305,6 +305,13 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' } + + It 'writes error for missing manifest module under $env:PSModulePath' { + $path = [System.IO.Path]::GetFullPath("$psModulePath\missing") + Test-Path $path | Should -BeFalse + { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + } } Describe 'Get-Module -ListAvailable with path' -Tags "CI" { From 8448b34f0bdbc348f6c035b2cc16829b6f291ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 16:00:34 +0200 Subject: [PATCH 07/82] Add new `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 50ead6d9802..cf23cbb3887 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -312,6 +312,9 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' } + + Context 'Locating existing script module' { + } } Describe 'Get-Module -ListAvailable with path' -Tags "CI" { From 231af68a5c6f714024bc8d886e3882eada9eafd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 16:00:51 +0200 Subject: [PATCH 08/82] Add `BeforeAll` and `AfterAll` --- .../Get-Module.Tests.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index cf23cbb3887..068f4b1f119 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -314,6 +314,24 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume } Context 'Locating existing script module' { + BeforeAll { + $psModulePath = ($env:PSModulePath -split ';')[0] + + # Script modules + # + # Under $env:PSModulePath. TODO: Is this a supported scenario? + $inPSModulePathLooseFilePath = Join-Path $psModulePath 'loose.psm1' + New-Item -ItemType File -Force $inPSModulePathLooseFilePath > $null + # + # Under $pwd + $inPSModulePathLooseFilePathPwd = Join-Path $pwd 'loose.psm1' + New-Item -ItemType File -Force $inPSModulePathLooseFilePathPwd > $null + } + + AfterAll { + Remove-Item $inPSModulePathLooseFilePath + Remove-Item $inPSModulePathLooseFilePathPwd + } } } From 6b75ee814cd1ec38701672d9a7b42285dd0b321c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 16:01:03 +0200 Subject: [PATCH 09/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 068f4b1f119..d69e11ddc54 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -332,6 +332,13 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume Remove-Item $inPSModulePathLooseFilePath Remove-Item $inPSModulePathLooseFilePathPwd } + + # TODO: This looks like a bug. + It 'wrongly writes error instead of returning module information for existing script module under $env:PSModulePath using basename' { + Test-Path "$psModulePath\loose.psm1" | Should -BeTrue + { Get-Module -ListAvailable -Name "$psModulePath\loose" -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + { Get-Module -ListAvailable -FullyQualifiedName "$psModulePath\loose" -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + } } } From 2b52fb6d8e9ce2f36f1f52e2e54a32cf3a3e9e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 16:01:15 +0200 Subject: [PATCH 10/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index d69e11ddc54..598db5a504b 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -339,6 +339,13 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume { Get-Module -ListAvailable -Name "$psModulePath\loose" -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' { Get-Module -ListAvailable -FullyQualifiedName "$psModulePath\loose" -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' } + + # TODO: This looks like a bug. + It 'wrongly writes error instead of returning module information for existing script module using basename' { + Test-Path "$pwd\loose.psm1" | Should -BeTrue + { Get-Module -ListAvailable -Name "$pwd\loose" -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + { Get-Module -ListAvailable -FullyQualifiedName "$pwd\loose" -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + } } } From 6258e72179508920a2f65f28c43b4a6d0b2266b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Mon, 10 Aug 2026 06:40:33 +0200 Subject: [PATCH 11/82] Review: Avoid Windows-only convention --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 598db5a504b..c5c0268af50 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -282,7 +282,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { BeforeAll { - $psModulePath = ($env:PSModulePath -split ';')[0] + $psModulePath = ($env:PSModulePath -split [System.IO.Path]::PathSeparator)[0] } It 'wrongly returns module information instead of $null or error for missing script module' { @@ -315,7 +315,7 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume Context 'Locating existing script module' { BeforeAll { - $psModulePath = ($env:PSModulePath -split ';')[0] + $psModulePath = ($env:PSModulePath -split [System.IO.Path]::PathSeparator)[0] # Script modules # From 95e9342c701ebbecdfaafade2b106927c4d7b0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Mon, 10 Aug 2026 06:46:16 +0200 Subject: [PATCH 12/82] Review: Use `Join-Path` --- .../Get-Module.Tests.ps1 | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index c5c0268af50..ebb55897926 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -286,28 +286,28 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume } It 'wrongly returns module information instead of $null or error for missing script module' { - $path = [System.IO.Path]::GetFullPath("$pwd\missing.psm1") + $path = [System.IO.Path]::GetFullPath((Join-Path $pwd missing.psm1)) Test-Path $path | Should -BeFalse Get-Module -ListAvailable -FullyQualifiedName $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) Get-Module -ListAvailable -Name $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) } It 'wrongly returns module information instead of $null or error for missing script module under $env:PSModulePath' { - $path = [System.IO.Path]::GetFullPath("$psModulePath\missing.psm1") + $path = [System.IO.Path]::GetFullPath((Join-Path $psModulePath missing.psm1)) Test-Path $path | Should -BeFalse Get-Module -ListAvailable -FullyQualifiedName $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) Get-Module -ListAvailable -Name $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) } It 'writes error for missing manifest module' { - $path = [System.IO.Path]::GetFullPath("$pwd\missing") + $path = [System.IO.Path]::GetFullPath((Join-Path $pwd missing)) Test-Path $path | Should -BeFalse { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' } It 'writes error for missing manifest module under $env:PSModulePath' { - $path = [System.IO.Path]::GetFullPath("$psModulePath\missing") + $path = [System.IO.Path]::GetFullPath((Join-Path $psModulePath missing)) Test-Path $path | Should -BeFalse { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' @@ -335,16 +335,16 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume # TODO: This looks like a bug. It 'wrongly writes error instead of returning module information for existing script module under $env:PSModulePath using basename' { - Test-Path "$psModulePath\loose.psm1" | Should -BeTrue - { Get-Module -ListAvailable -Name "$psModulePath\loose" -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' - { Get-Module -ListAvailable -FullyQualifiedName "$psModulePath\loose" -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + Test-Path (Join-Path $psModulePath loose.psm1) | Should -BeTrue + { Get-Module -ListAvailable -Name (Join-Path $psModulePath loose) -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + { Get-Module -ListAvailable -FullyQualifiedName (Join-Path $psModulePath loose) -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' } # TODO: This looks like a bug. It 'wrongly writes error instead of returning module information for existing script module using basename' { - Test-Path "$pwd\loose.psm1" | Should -BeTrue - { Get-Module -ListAvailable -Name "$pwd\loose" -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' - { Get-Module -ListAvailable -FullyQualifiedName "$pwd\loose" -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + Test-Path (Join-Path $pwd loose.psm1) | Should -BeTrue + { Get-Module -ListAvailable -Name (Join-Path $pwd loose) -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + { Get-Module -ListAvailable -FullyQualifiedName (Join-Path $pwd loose) -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' } } } From 8dbc54d802b2facd1fa605fa47701601757f414b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Mon, 10 Aug 2026 07:09:11 +0200 Subject: [PATCH 13/82] Review: Fix `Should -Throw` tests --- .../Get-Module.Tests.ps1 | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index ebb55897926..a4a823554b5 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -302,15 +302,23 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume It 'writes error for missing manifest module' { $path = [System.IO.Path]::GetFullPath((Join-Path $pwd missing)) Test-Path $path | Should -BeFalse - { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' - { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + + $err = { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' + + $err = { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' } It 'writes error for missing manifest module under $env:PSModulePath' { $path = [System.IO.Path]::GetFullPath((Join-Path $psModulePath missing)) Test-Path $path | Should -BeFalse - { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' - { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + + $err = { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' + + $err = { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' } Context 'Locating existing script module' { @@ -336,15 +344,23 @@ Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argume # TODO: This looks like a bug. It 'wrongly writes error instead of returning module information for existing script module under $env:PSModulePath using basename' { Test-Path (Join-Path $psModulePath loose.psm1) | Should -BeTrue - { Get-Module -ListAvailable -Name (Join-Path $psModulePath loose) -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' - { Get-Module -ListAvailable -FullyQualifiedName (Join-Path $psModulePath loose) -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + + $err = { Get-Module -ListAvailable -Name (Join-Path $psModulePath loose) -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' + + $err = { Get-Module -ListAvailable -FullyQualifiedName (Join-Path $psModulePath loose) -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' } # TODO: This looks like a bug. It 'wrongly writes error instead of returning module information for existing script module using basename' { Test-Path (Join-Path $pwd loose.psm1) | Should -BeTrue - { Get-Module -ListAvailable -Name (Join-Path $pwd loose) -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' - { Get-Module -ListAvailable -FullyQualifiedName (Join-Path $pwd loose) -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + + $err = { Get-Module -ListAvailable -Name (Join-Path $pwd loose) -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' + + $err = { Get-Module -ListAvailable -FullyQualifiedName (Join-Path $pwd loose) -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' } } } From bb7d1db6d305e4b5c76adc2e8922d6ac08f867ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Mon, 10 Aug 2026 07:10:23 +0200 Subject: [PATCH 14/82] Review: Typo --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index a4a823554b5..5211077b96b 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -280,7 +280,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { } } -Describe 'Get-Module -ListAvaiable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { +Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { BeforeAll { $psModulePath = ($env:PSModulePath -split [System.IO.Path]::PathSeparator)[0] } From 0b6503e61fef5d604bc6e0acb547c62438941c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Mon, 10 Aug 2026 07:15:09 +0200 Subject: [PATCH 15/82] Review: Use dedicated $env:PSModulePath for tests --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 5211077b96b..05c0b615702 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -282,7 +282,13 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { BeforeAll { - $psModulePath = ($env:PSModulePath -split [System.IO.Path]::PathSeparator)[0] + $oldPSModulePath = $env:PSModulePath + $psModulePath = New-Item -ItemType Directory (Join-Path $TestDrive modules) + $env:PSModulePath = $psModulePath + } + + AfterAll { + $env:PSModulePath = $oldPSModulePath } It 'wrongly returns module information instead of $null or error for missing script module' { From c6d6a31faf4ce0814ddf64d71f8bd29318dedf4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Mon, 10 Aug 2026 07:18:33 +0200 Subject: [PATCH 16/82] Refactor --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 05c0b615702..2017872ba16 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -329,7 +329,7 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Context 'Locating existing script module' { BeforeAll { - $psModulePath = ($env:PSModulePath -split [System.IO.Path]::PathSeparator)[0] + $psModulePath = $env:PSModulePath # Script modules # From 45075a96eb1496d6af5401fb57e06f7777a24a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Mon, 10 Aug 2026 21:58:49 +0200 Subject: [PATCH 17/82] Fix name --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 2017872ba16..5ff8e078008 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -338,13 +338,13 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum New-Item -ItemType File -Force $inPSModulePathLooseFilePath > $null # # Under $pwd - $inPSModulePathLooseFilePathPwd = Join-Path $pwd 'loose.psm1' - New-Item -ItemType File -Force $inPSModulePathLooseFilePathPwd > $null + $inCwdLooseFilePath = Join-Path $pwd 'loose.psm1' + New-Item -ItemType File -Force $inCwdLooseFilePath > $null } AfterAll { Remove-Item $inPSModulePathLooseFilePath - Remove-Item $inPSModulePathLooseFilePathPwd + Remove-Item $inCwdLooseFilePath } # TODO: This looks like a bug. From 0f4e5fbeefabb75e04240c5981b8637802e99f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:05:59 +0200 Subject: [PATCH 18/82] Refactor: Use single variable for the same data --- .../Get-Module.Tests.ps1 | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 5ff8e078008..18aea8ccc16 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -283,8 +283,7 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { BeforeAll { $oldPSModulePath = $env:PSModulePath - $psModulePath = New-Item -ItemType Directory (Join-Path $TestDrive modules) - $env:PSModulePath = $psModulePath + $env:PSModulePath = New-Item -ItemType Directory (Join-Path $TestDrive modules) } AfterAll { @@ -299,7 +298,7 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } It 'wrongly returns module information instead of $null or error for missing script module under $env:PSModulePath' { - $path = [System.IO.Path]::GetFullPath((Join-Path $psModulePath missing.psm1)) + $path = [System.IO.Path]::GetFullPath((Join-Path $env:PSModulePath missing.psm1)) Test-Path $path | Should -BeFalse Get-Module -ListAvailable -FullyQualifiedName $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) Get-Module -ListAvailable -Name $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) @@ -317,7 +316,7 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } It 'writes error for missing manifest module under $env:PSModulePath' { - $path = [System.IO.Path]::GetFullPath((Join-Path $psModulePath missing)) + $path = [System.IO.Path]::GetFullPath((Join-Path $env:PSModulePath missing)) Test-Path $path | Should -BeFalse $err = { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -PassThru @@ -329,12 +328,12 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Context 'Locating existing script module' { BeforeAll { - $psModulePath = $env:PSModulePath + $env:PSModulePath = $env:PSModulePath # Script modules # # Under $env:PSModulePath. TODO: Is this a supported scenario? - $inPSModulePathLooseFilePath = Join-Path $psModulePath 'loose.psm1' + $inPSModulePathLooseFilePath = Join-Path $env:PSModulePath 'loose.psm1' New-Item -ItemType File -Force $inPSModulePathLooseFilePath > $null # # Under $pwd @@ -349,12 +348,12 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum # TODO: This looks like a bug. It 'wrongly writes error instead of returning module information for existing script module under $env:PSModulePath using basename' { - Test-Path (Join-Path $psModulePath loose.psm1) | Should -BeTrue + Test-Path (Join-Path $env:PSModulePath loose.psm1) | Should -BeTrue - $err = { Get-Module -ListAvailable -Name (Join-Path $psModulePath loose) -ErrorAction Stop } | Should -Throw -PassThru + $err = { Get-Module -ListAvailable -Name (Join-Path $env:PSModulePath loose) -ErrorAction Stop } | Should -Throw -PassThru $err.Exception.Message | Should -BeLike '*Update the Name parameter*' - $err = { Get-Module -ListAvailable -FullyQualifiedName (Join-Path $psModulePath loose) -ErrorAction Stop } | Should -Throw -PassThru + $err = { Get-Module -ListAvailable -FullyQualifiedName (Join-Path $env:PSModulePath loose) -ErrorAction Stop } | Should -Throw -PassThru $err.Exception.Message | Should -BeLike '*Update the Name parameter*' } From c56d882160b3819cbb704da71bef9b65798e9c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:06:24 +0200 Subject: [PATCH 19/82] Consistent formatting --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 18aea8ccc16..0e519f43d64 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -293,6 +293,7 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum It 'wrongly returns module information instead of $null or error for missing script module' { $path = [System.IO.Path]::GetFullPath((Join-Path $pwd missing.psm1)) Test-Path $path | Should -BeFalse + Get-Module -ListAvailable -FullyQualifiedName $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) Get-Module -ListAvailable -Name $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) } @@ -300,6 +301,7 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum It 'wrongly returns module information instead of $null or error for missing script module under $env:PSModulePath' { $path = [System.IO.Path]::GetFullPath((Join-Path $env:PSModulePath missing.psm1)) Test-Path $path | Should -BeFalse + Get-Module -ListAvailable -FullyQualifiedName $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) Get-Module -ListAvailable -Name $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) } From 8a0a003db3c3eda8e20a0cd1d227267e09b2d510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:09:07 +0200 Subject: [PATCH 20/82] Refactor: Consolidate variables --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 0e519f43d64..23947810929 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -351,22 +351,24 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum # TODO: This looks like a bug. It 'wrongly writes error instead of returning module information for existing script module under $env:PSModulePath using basename' { Test-Path (Join-Path $env:PSModulePath loose.psm1) | Should -BeTrue + $path = Join-Path $env:PSModulePath loose - $err = { Get-Module -ListAvailable -Name (Join-Path $env:PSModulePath loose) -ErrorAction Stop } | Should -Throw -PassThru + $err = { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -PassThru $err.Exception.Message | Should -BeLike '*Update the Name parameter*' - $err = { Get-Module -ListAvailable -FullyQualifiedName (Join-Path $env:PSModulePath loose) -ErrorAction Stop } | Should -Throw -PassThru + $err = { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -PassThru $err.Exception.Message | Should -BeLike '*Update the Name parameter*' } # TODO: This looks like a bug. It 'wrongly writes error instead of returning module information for existing script module using basename' { Test-Path (Join-Path $pwd loose.psm1) | Should -BeTrue + $path = Join-Path $pwd loose - $err = { Get-Module -ListAvailable -Name (Join-Path $pwd loose) -ErrorAction Stop } | Should -Throw -PassThru + $err = { Get-Module -ListAvailable -Name $path -ErrorAction Stop } | Should -Throw -PassThru $err.Exception.Message | Should -BeLike '*Update the Name parameter*' - $err = { Get-Module -ListAvailable -FullyQualifiedName (Join-Path $pwd loose) -ErrorAction Stop } | Should -Throw -PassThru + $err = { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -PassThru $err.Exception.Message | Should -BeLike '*Update the Name parameter*' } } From c2bf6cff4d382e8b50fcf2e6a07e8100e4587020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:40:58 +0200 Subject: [PATCH 21/82] Cleanup --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 23947810929..17bc6e2526a 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -330,8 +330,6 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Context 'Locating existing script module' { BeforeAll { - $env:PSModulePath = $env:PSModulePath - # Script modules # # Under $env:PSModulePath. TODO: Is this a supported scenario? From 7dd54977b4a0fa611d17260b3b8142a99ba2a98f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:42:39 +0200 Subject: [PATCH 22/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 17bc6e2526a..9f4daa703fd 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -369,6 +369,19 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $err = { Get-Module -ListAvailable -FullyQualifiedName $path -ErrorAction Stop } | Should -Throw -PassThru $err.Exception.Message | Should -BeLike '*Update the Name parameter*' } + + It 'returns module information for existing script module using file name' { + $path = Join-Path $pwd loose.psm1 + Test-Path $path | Should -BeTrue + + $actual = Get-Module -ListAvailable -Name $path + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly $path + + $actual = Get-Module -ListAvailable -FullyQualifiedName $path + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly $path + } } } From 92c622fd5f0816b46d51ba05bb1c3ca4ee66fda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:43:09 +0200 Subject: [PATCH 23/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 9f4daa703fd..ee2566e287a 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -382,6 +382,19 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual | Should -HaveCount 1 $actual[0].Path | Should -BeExactly $path } + + It 'returns module information for existing script module under $env:PSModulePath using file name' { + $path = Join-Path $env:PSModulePath loose.psm1 + Test-Path $path | Should -BeTrue + + $actual = Get-Module -ListAvailable -Name $path + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly $path + + $actual = Get-Module -ListAvailable -FullyQualifiedName $path + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly $path + } } } From 4087b48801de1bf9b4350ecd2e9d34f4ce8a8bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:43:26 +0200 Subject: [PATCH 24/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index ee2566e287a..535ef997cea 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -396,6 +396,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual[0].Path | Should -BeExactly $path } } + + Context 'When argument contains wildcards' { + } } Describe 'Get-Module -ListAvailable with path' -Tags "CI" { From 3dbf91e4a324f036a17e9675e64c5cdfd3e631d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:43:43 +0200 Subject: [PATCH 25/82] Add `BeforeAll` and `AfterAll` --- .../Get-Module.Tests.ps1 | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 535ef997cea..7e637e01f3f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -398,6 +398,61 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'When argument contains wildcards' { + BeforeAll { + # Manifest modules under $env:PSModulePath + # + # Versioned, manifest + $inPSModulePathWithManifestFileName = 'existing' + $inPSModulePatWithManifestDirectory = Join-Path $env:PSModulePath $inPSModulePathWithManifestFileName '0.0.1' + $inPSModulePathWithManifestFilePath = Join-Path $inPSModulePatWithManifestDirectory "$inPSModulePathWithManifestFileName.psm1" + New-Item -ItemType File -Force $inPSModulePathWithManifestFilePath > $null + New-ModuleManifest -Path (Join-Path $inPSModulePatWithManifestDirectory "$inPSModulePathWithManifestFileName.psd1") + # + # Versioned, manifest + $inPSModulePathWithManifestFileName2 = 'existing2' + $inPSModulePatWithManifestDirectory2 = Join-Path $env:PSModulePath $inPSModulePathWithManifestFileName2 '0.0.1' + $inPSModulePathWithManifestFilePath2 = Join-Path $inPSModulePatWithManifestDirectory2 "$inPSModulePathWithManifestFileName2.psm1" + New-Item -ItemType File -Force $inPSModulePathWithManifestFilePath2 > $null + New-ModuleManifest -Path (Join-Path $inPSModulePatWithManifestDirectory2 "$inPSModulePathWithManifestFileName2.psd1") + + # Manifest modules under $pwd + # + # Versioned, manifest + $inCwdhWithManifestFileName = 'existing' + $inCwdWithManifestDirectory = Join-Path $pwd $inCwdhWithManifestFileName '0.0.1' + $inCwdWithManifestFilePath = Join-Path $inCwdWithManifestDirectory "$inCwdhWithManifestFileName.psm1" + New-Item -ItemType File -Force $inCwdWithManifestFilePath > $null + New-ModuleManifest -Path (Join-Path $inCwdWithManifestDirectory "$inCwdhWithManifestFileName.psd1") + # + # Versioned, manifest + $inCwdWithManifestFileName2 = 'existing2' + $inCwdWithManifestDirectory2 = Join-Path $pwd $inCwdWithManifestFileName2 '0.0.1' + $inCwdWithManifestFilePath2 = Join-Path $inCwdWithManifestDirectory2 "$inCwdWithManifestFileName2.psm1" + New-Item -ItemType File -Force $inCwdWithManifestFilePath2 > $null + New-ModuleManifest -Path (Join-Path $inCwdWithManifestDirectory2 "$inCwdWithManifestFileName2.psd1") + + # Script modules + # + # Under $env:PSModulePath. TODO: Is this a supported scenario? + $inPSModulePathLooseFilePath = Join-Path $env:PSModulePath 'loose.psm1' + New-Item -ItemType File -Force $inPSModulePathLooseFilePath > $null + # + # + # Under $pwd + $inCwdFilePath = Join-Path $pwd 'loose.psm1' + New-Item -ItemType File -Force $inCwdFilePath > $null + } + + AfterAll { + Remove-Item -Force -Recurse $inPSModulePatWithManifestDirectory + Remove-Item -Force -Recurse $inPSModulePatWithManifestDirectory2 + + Remove-Item -Force -Recurse $inCwdWithManifestDirectory + Remove-Item -Force -Recurse $inCwdWithManifestDirectory2 + + Remove-Item $inPSModulePathLooseFilePath + Remove-Item $inCwdFilePath + } } } From dbf05874b590a66837817808a7d52500a0e8cc82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:43:49 +0200 Subject: [PATCH 26/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 7e637e01f3f..9f2fe400f39 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -453,6 +453,18 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Remove-Item $inPSModulePathLooseFilePath Remove-Item $inCwdFilePath } + + It 'returns existing manifest modules under $env:PSModulePath when using the -Name parameter' { + $moduleManifestPath1 = Join-Path $env:PSModulePath existing 0.0.1,existing.psd1 + $moduleManifestPath2 = Join-Path $env:PSModulePath existing2 0.0.1,existing2.psd1 + Test-Path $moduleManifestPath1 | Should -BeTrue + Test-Path $moduleManifestPath2 | Should -BeTrue + + $actual = Get-Module -ListAvailable -Name (Join-Path $env:PSModulePath 'existing*') + $actual | Should -HaveCount 2 + $actual[0].Path | Should -BeExactly $moduleManifestPath1 + $actual[1].Path | Should -BeExactly $moduleManifestPath2 + } } } From 592a4a116c76815bac687837662b8b3735d3e891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:43:56 +0200 Subject: [PATCH 27/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 9f2fe400f39..c7046e2c4e2 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -465,6 +465,12 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual[0].Path | Should -BeExactly $moduleManifestPath1 $actual[1].Path | Should -BeExactly $moduleManifestPath2 } + + # TODO: This looks like a bug. + It 'wrongly returns $null for existing manifest modules under $env:PSModulePath when using the -FullyQualifiedName parameter' { + $actual = Get-Module -ListAvailable -FullyQualifiedName (Join-Path $env:PSModulePath 'existing*') + $actual | Should -Be $null + } } } From 11edc827f8428f8b184de74df7f0dfaf4fea70f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:44:01 +0200 Subject: [PATCH 28/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index c7046e2c4e2..9256b428c5d 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -471,6 +471,18 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual = Get-Module -ListAvailable -FullyQualifiedName (Join-Path $env:PSModulePath 'existing*') $actual | Should -Be $null } + + It 'returns existing manifest modules when using the -Name parameter' { + $moduleManifestPath1 = Join-Path $pwd existing 0.0.1,existing.psd1 + $moduleManifestPath2 = Join-Path $pwd existing2 0.0.1,existing2.psd1 + Test-Path $moduleManifestPath1 | Should -BeTrue + Test-Path $moduleManifestPath2 | Should -BeTrue + + $actual = Get-Module -ListAvailable -Name (Join-Path $pwd 'existing*') + $actual | Should -HaveCount 2 + $actual[0].Path | Should -BeExactly $moduleManifestPath1 + $actual[1].Path | Should -BeExactly $moduleManifestPath2 + } } } From 8e822c668d833665cd17fd620ff36c72b331a051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:44:08 +0200 Subject: [PATCH 29/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 9256b428c5d..010ab76e0a5 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -483,6 +483,12 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual[0].Path | Should -BeExactly $moduleManifestPath1 $actual[1].Path | Should -BeExactly $moduleManifestPath2 } + + # TODO: This looks like a bug. + It 'wrongly returns $null for existing manifest modules when using the -FullyQualifiedName parameter' { + $actual = Get-Module -ListAvailable -FullyQualifiedName (Join-Path $pwd 'existing*') + $actual | Should -Be $null + } } } From f385bcddc0b988819085c7af01da539ece39bc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:44:13 +0200 Subject: [PATCH 30/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 010ab76e0a5..fb3be7ed048 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -489,6 +489,12 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual = Get-Module -ListAvailable -FullyQualifiedName (Join-Path $pwd 'existing*') $actual | Should -Be $null } + + It 'returns module information for existing script module under $env:PSModulePath' { + $actual = Get-Module -ListAvailable -Name (Join-Path $env:PSModulePath 'loose*') + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly (Join-Path $env:PSModulePath loose.psm1) + } } } From 5154898d2372d771e6147591adfb7738e9d30404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 07:44:18 +0200 Subject: [PATCH 31/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index fb3be7ed048..72e5dd45812 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -495,6 +495,19 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual | Should -HaveCount 1 $actual[0].Path | Should -BeExactly (Join-Path $env:PSModulePath loose.psm1) } + + It 'returns module information for existing script module using file name' { + $path = Join-Path $pwd loose.psm1 + Test-Path $path | Should -BeTrue + + $actual = Get-Module -ListAvailable -Name $path + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly $path + + $actual = Get-Module -ListAvailable -FullyQualifiedName $path + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly $path + } } } From 8afb65f9403dcb574ec2959f903d1b0c9dc49c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 17:22:23 +0200 Subject: [PATCH 32/82] Add `Describe` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 72e5dd45812..ad47a283c70 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -280,6 +280,9 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { } } +Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is relative-rooted' -Tags "CI" { +} + Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { BeforeAll { $oldPSModulePath = $env:PSModulePath From 0d362fe0b60059049e427432b9dfe8c047676494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 17:22:34 +0200 Subject: [PATCH 33/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index ad47a283c70..9bce7ba983e 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -281,6 +281,17 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is relative-rooted' -Tags "CI" { + It 'wrongly returns module information instead of $null or error for missing script module' { + $path1 = Join-Path . missing.psm1 + $path2 = Join-Path .. missing.psm1 + Test-Path $path1 | Should -BeFalse + Test-Path $path2 | Should -BeFalse + + Get-Module -ListAvailable -Name $path1 | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + Get-Module -ListAvailable -Name $path2 | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + Get-Module -ListAvailable -FullyQualifiedName $path1 | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + Get-Module -ListAvailable -FullyQualifiedName $path2 | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { From 5d8168cc78ac0ec79c138249c6dfa29bc5ce5372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 17:22:44 +0200 Subject: [PATCH 34/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 9bce7ba983e..0edab2a6891 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -292,6 +292,18 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Get-Module -ListAvailable -FullyQualifiedName $path1 | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) Get-Module -ListAvailable -FullyQualifiedName $path2 | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) } + + It 'writes error for missing manifest module' { + $path1 = Join-Path . missing + $path2 = Join-Path .. missing + Test-Path $path1 | Should -BeFalse + Test-Path $path2 | Should -BeFalse + + { Get-Module -ListAvailable -Name $path1 -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + { Get-Module -ListAvailable -Name $path2 -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + { Get-Module -ListAvailable -FullyQualifiedName $path1 -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + { Get-Module -ListAvailable -FullyQualifiedName $path2 -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { From 52ec5a068d2f94d77cf8d24991a78bdd059f193c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 17:23:10 +0200 Subject: [PATCH 35/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 0edab2a6891..d3a8e5845b4 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -304,6 +304,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum { Get-Module -ListAvailable -FullyQualifiedName $path1 -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' { Get-Module -ListAvailable -FullyQualifiedName $path2 -ErrorAction Stop } | Should -Throw -Because '*Update the Name parameter*' } + + Context 'Locating existing script module' { + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { From f28cb52e623a7f0c6d614b7ce982b97f35e47224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 17:23:22 +0200 Subject: [PATCH 36/82] Add `BeforeAll` and `AfterAll` --- .../Get-Module.Tests.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index d3a8e5845b4..08389490311 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -306,6 +306,22 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'Locating existing script module' { + BeforeAll { + # Script modules + # + # Under $env:PSModulePath. TODO: Is this a supported scenario? + $inPSModulePathLooseFilePath = Join-Path . loose.psm1 + New-Item -ItemType File -Force $inPSModulePathLooseFilePath > $null + # + # Under $pwd + $inPSModulePathLooseFilePathParent = Join-Path .. loose.psm1 + New-Item -ItemType File -Force $inPSModulePathLooseFilePathParent > $null + } + + AfterAll { + Remove-Item $inPSModulePathLooseFilePath + Remove-Item $inPSModulePathLooseFilePathParent + } } } From ff1c480019292b5af500ca180a798923474bc7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 17:23:29 +0200 Subject: [PATCH 37/82] Add test --- .../Get-Module.Tests.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 08389490311..90e528363e8 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -322,6 +322,23 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Remove-Item $inPSModulePathLooseFilePath Remove-Item $inPSModulePathLooseFilePathParent } + + # TODO: This looks like a bug. + It 'wrongly writes error instead of returning module information for existing script module using basename' { + $path1 = Join-Path . loose.psm1 + $path2 = Join-Path .. loose.psm1 + Test-Path $path1 | Should -BeTrue + Test-Path $path2 | Should -BeTrue + + $name1 = Join-Path . loose + $name2 = Join-Path .. loose + + $err = { Get-Module -ListAvailable -Name $name1 -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' + + $err = { Get-Module -ListAvailable -Name $name2 -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' + } } } From 9620dac3deb55089e8b67dde924717962e9fd322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 17:23:37 +0200 Subject: [PATCH 38/82] Add test --- .../Get-Module.Tests.ps1 | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 90e528363e8..fba9c99d0d6 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -339,6 +339,29 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $err = { Get-Module -ListAvailable -Name $name2 -ErrorAction Stop } | Should -Throw -PassThru $err.Exception.Message | Should -BeLike '*Update the Name parameter*' } + + It 'returns module information for existing script module using file name' { + $name1 = Join-Path . loose.psm1 + $name2 = Join-Path .. loose.psm1 + Test-Path $name1 | Should -BeTrue + Test-Path $name2 | Should -BeTrue + + $actual = Get-Module -ListAvailable -Name $name1 + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly ([System.IO.Path]::GetFullPath($name1)) + + $actual = Get-Module -ListAvailable -Name $name2 + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly ([System.IO.Path]::GetFullPath($name2)) + + $actual = Get-Module -ListAvailable -FullyQualifiedName $name1 + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly ([System.IO.Path]::GetFullPath($name1)) + + $actual = Get-Module -ListAvailable -FullyQualifiedName $name2 + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly ([System.IO.Path]::GetFullPath($name2)) + } } } From 3a3837bdbce49e12838c05a4996965041794deec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 20:27:47 +0200 Subject: [PATCH 39/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index fba9c99d0d6..1e864900a9e 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -363,6 +363,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual[0].Path | Should -BeExactly ([System.IO.Path]::GetFullPath($name2)) } } + + Context 'When argument contains wildcards' { + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is absolute path' -Tags "CI" { From f06e705166d5b5fb9471e532adb79e31bc9698de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 17:29:33 +0200 Subject: [PATCH 40/82] Add `BeforeAll` and `AfterAll` --- .../Get-Module.Tests.ps1 | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 1e864900a9e..e82143c2554 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -365,6 +365,59 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'When argument contains wildcards' { + BeforeAll { + # Manifest modules under '.' + # + # Versioned, manifest + $inCwdWithManifestFileName = 'existing' + $inCwdWithManifestDirectory = Join-Path '.' $inCwdWithManifestFileName '0.0.1' + $inCwdWithManifestFilePath = Join-Path $inCwdWithManifestDirectory "$inCwdWithManifestFileName.psm1" + New-Item -ItemType File -Force $inCwdWithManifestFilePath > $null + New-ModuleManifest -Path (Join-Path $inCwdWithManifestDirectory "$inCwdWithManifestFileName.psd1") + # + # Versioned, manifest + $inCwdWithManifestFileName2 = 'existing2' + $inCwdWithManifestDirectory2 = Join-Path '.' $inCwdWithManifestFileName2 '0.0.1' + $inCwdWithManifestFilePath2 = Join-Path $inCwdWithManifestDirectory2 "$inCwdWithManifestFileName2.psm1" + New-Item -ItemType File -Force $inCwdWithManifestFilePath2 > $null + New-ModuleManifest -Path (Join-Path $inCwdWithManifestDirectory2 "$inCwdWithManifestFileName2.psd1") + + # Manifest modules under '..' + # + # Versioned, manifest + $inParentWithManifestFileName = 'existing' + $inParentWithManifestDirectory = Join-Path '..' $inParentWithManifestFileName '0.0.1' + $inParentWithManifestFilePath = Join-Path $inParentWithManifestDirectory "$inParentWithManifestFileName.psm1" + New-Item -ItemType File -Force $inParentWithManifestFilePath > $null + New-ModuleManifest -Path (Join-Path $inParentWithManifestDirectory "$inParentWithManifestFileName.psd1") + # + # Versioned, manifest + $inParentWithManifestFileName2 = 'existing2' + $inParentWithManifestDirectory2 = Join-Path '..' $inParentWithManifestFileName2 '0.0.1' + $inParentWithManifestFilePath2 = Join-Path $inParentWithManifestDirectory2 "$inParentWithManifestFileName2.psm1" + New-Item -ItemType File -Force $inParentWithManifestFilePath2 > $null + New-ModuleManifest -Path (Join-Path $inParentWithManifestDirectory2 "$inParentWithManifestFileName2.psd1") + + # Script modules under '.' and '..' + # + # Under '.' + $inCwdLooseFilePath = Join-Path '.' 'loose.psm1' + New-Item -ItemType File -Force $inCwdLooseFilePath > $null + # + # Under '..' + $inParentLooseFilePath = Join-Path '..' 'loose.psm1' + New-Item -ItemType File -Force $inParentLooseFilePath > $null + } + + AfterAll { + Remove-Item -Force -Recurse $inCwdWithManifestDirectory + Remove-Item -Force -Recurse $inCwdWithManifestDirectory2 + + Remove-Item -Force -Recurse $inParentWithManifestDirectory + Remove-Item -Force -Recurse $inParentWithManifestDirectory2 + + Remove-Item $inCwdLooseFilePath + } } } From 6d932612adaa8b723aed6121e7917986767339ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 17:29:39 +0200 Subject: [PATCH 41/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index e82143c2554..b51a94abb5a 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -418,6 +418,18 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Remove-Item $inCwdLooseFilePath } + + It 'returns existing manifest modules when using the -Name parameter' { + $actual = Get-Module -ListAvailable -Name '.\existing*' + $actual | Should -HaveCount 2 + $actual[0].Path | Should -BeExactly ([System.IO.Path]::GetFullPath('.\existing\0.0.1\existing.psd1')) + $actual[1].Path | Should -BeExactly ([System.IO.Path]::GetFullPath('.\existing2\0.0.1\existing2.psd1')) + + $actual = Get-Module -ListAvailable -Name '..\existing*' + $actual | Should -HaveCount 2 + $actual[0].Path | Should -BeExactly ([System.IO.Path]::GetFullPath('..\existing\0.0.1\existing.psd1')) + $actual[1].Path | Should -BeExactly ([System.IO.Path]::GetFullPath('..\existing2\0.0.1\existing2.psd1')) + } } } From c8356e6a467fb35e493590f36689beae24e7df73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 17:29:45 +0200 Subject: [PATCH 42/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index b51a94abb5a..7b99bc4af47 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -430,6 +430,15 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual[0].Path | Should -BeExactly ([System.IO.Path]::GetFullPath('..\existing\0.0.1\existing.psd1')) $actual[1].Path | Should -BeExactly ([System.IO.Path]::GetFullPath('..\existing2\0.0.1\existing2.psd1')) } + + # TODO: This looks like a bug. + It 'wrongly returns $null for existing manifest modules when using the -FullyQualifiedName parameter' { + $actual = Get-Module -ListAvailable -FullyQualifiedName '.\existing*' + $actual | Should -Be $null + + $actual = Get-Module -ListAvailable -FullyQualifiedName '..\existing*' + $actual | Should -Be $null + } } } From aa7e56d3325df3932bca79e2912f89c699ea6b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 17:29:52 +0200 Subject: [PATCH 43/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 7b99bc4af47..9fc62c435dc 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -439,6 +439,16 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual = Get-Module -ListAvailable -FullyQualifiedName '..\existing*' $actual | Should -Be $null } + + It 'returns module information for existing script module' { + $actual = Get-Module -ListAvailable -Name '.\loose*' + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly ([System.IO.Path]::GetFullPath('.\loose.psm1')) + + $actual = Get-Module -ListAvailable -FullyQualifiedName '..\loose*' + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly ([System.IO.Path]::GetFullPath('..\loose.psm1')) + } } } From d0f5508ad7efacb1147b020a8117c7de0e340dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:32:55 +0200 Subject: [PATCH 44/82] Add `Describe` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 9fc62c435dc..d394f493c44 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -280,6 +280,9 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { } } +Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is home-rooted' -Tags "CI" { +} + Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is relative-rooted' -Tags "CI" { It 'wrongly returns module information instead of $null or error for missing script module' { $path1 = Join-Path . missing.psm1 From 19c392ac89d3536ab4354328cb1258e4b3f77223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:33:10 +0200 Subject: [PATCH 45/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index d394f493c44..119a6a3cb7c 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -281,6 +281,14 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is home-rooted' -Tags "CI" { + It 'wrongly does not expand ''~'' to $HOME' { + $path = Join-Path ~ missing.psm1 + Test-Path $path | Should -BeFalse + + Get-Module -ListAvailable -Name $path | ForEach-Object Path | Should -BeExactly (Join-Path $HOME missing.psm1) + # TODO: This is a bug. + Get-Module -ListAvailable -FullyQualifiedName $path | ForEach-Object Path | Should -BeExactly (Join-Path $pwd $path) + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is relative-rooted' -Tags "CI" { From b75d60e517472d2cf306cbe6bbf88d7cfd9f6ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:33:20 +0200 Subject: [PATCH 46/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 119a6a3cb7c..0f3102a6b31 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -289,6 +289,14 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum # TODO: This is a bug. Get-Module -ListAvailable -FullyQualifiedName $path | ForEach-Object Path | Should -BeExactly (Join-Path $pwd $path) } + + It 'wrongly returns module information instead of $null or error for missing script module' { + $path = Join-Path ~ missing.psm1 + Test-Path $path | Should -BeFalse + + Get-Module -ListAvailable -Name $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + Get-Module -ListAvailable -FullyQualifiedName $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is relative-rooted' -Tags "CI" { From 1c653629c17a93300c0c209d0f5779fc6a3f5d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:33:31 +0200 Subject: [PATCH 47/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 0f3102a6b31..b35d5a4dbeb 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -297,6 +297,19 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Get-Module -ListAvailable -Name $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) Get-Module -ListAvailable -FullyQualifiedName $path | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) } + + It 'writes error for missing manifest module' { + $path = Join-Path ~ missing.psm1 + Test-Path $path | Should -BeFalse + + $name = Join-Path ~ missing + + $err = { Get-Module -ListAvailable -Name $name -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' + + $err = { Get-Module -ListAvailable -FullyQualifiedName $name -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is relative-rooted' -Tags "CI" { From f4ea1ea38fd8cac1c43f4d5213c3e75dbda67577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:33:47 +0200 Subject: [PATCH 48/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index b35d5a4dbeb..74bbf9b9f7a 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -310,6 +310,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $err = { Get-Module -ListAvailable -FullyQualifiedName $name -ErrorAction Stop } | Should -Throw -PassThru $err.Exception.Message | Should -BeLike '*Update the Name parameter*' } + + Context 'Locating existing script module' { + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is relative-rooted' -Tags "CI" { From 2fcbc0ce017ac33cee1369ebf270ef035af4e7fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:34:08 +0200 Subject: [PATCH 49/82] Add `BeforeAll` and `AfterAll` --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 74bbf9b9f7a..09b71cfe329 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -312,6 +312,16 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'Locating existing script module' { + BeforeAll { + # Script modules + # + $inHomeLooseFilePath = Join-Path $HOME loose.psm1 + New-Item -ItemType File -Force $inHomeLooseFilePath > $null + } + + AfterAll { + Remove-Item $inHomeLooseFilePath + } } } From eb36cb1249c9c854b02de2cd5bf174dce3835084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:34:15 +0200 Subject: [PATCH 50/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 09b71cfe329..1dff9ff729c 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -322,6 +322,20 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum AfterAll { Remove-Item $inHomeLooseFilePath } + + # TODO: This looks like a bug. + It 'wrongly writes error instead of returning module information for existing script module using basename' { + $path = Join-Path ~ loose.psm1 + Test-Path $path | Should -BeTrue + + $name = Join-Path ~ loose + + $err = { Get-Module -ListAvailable -Name $name -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' + + $err = { Get-Module -ListAvailable -FullyQualifiedName $name -ErrorAction Stop } | Should -Throw -PassThru + $err.Exception.Message | Should -BeLike '*Update the Name parameter*' + } } } From cfe48552ec798020eabd30e9301fc0c948ba66dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:34:24 +0200 Subject: [PATCH 51/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 1dff9ff729c..d1d9d430bf5 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -336,6 +336,20 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $err = { Get-Module -ListAvailable -FullyQualifiedName $name -ErrorAction Stop } | Should -Throw -PassThru $err.Exception.Message | Should -BeLike '*Update the Name parameter*' } + + It 'returns module information for existing script module using file name' { + $path = Join-Path ~ loose.psm1 + Test-Path $path | Should -BeTrue + + $actual = Get-Module -ListAvailable -Name $path + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly (Join-Path $HOME loose.psm1) + + # TODO: This is a bug. + $actual = Get-Module -ListAvailable -FullyQualifiedName $path + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly (Join-Path $pwd $path) + } } } From 0deccbeb7c3c1b5fef93b73db1a4f06c0c972045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:34:36 +0200 Subject: [PATCH 52/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index d1d9d430bf5..8aba55bed72 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -351,6 +351,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual[0].Path | Should -BeExactly (Join-Path $pwd $path) } } + + Context 'When argument contains wildcards' { + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is relative-rooted' -Tags "CI" { From 2fec8f5de48260206c21e3dd0d6bf4b38925ede9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:34:51 +0200 Subject: [PATCH 53/82] Add `BeforeAll` and `AfterAll` --- .../Get-Module.Tests.ps1 | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 8aba55bed72..93f88ac15c2 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -353,6 +353,35 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'When argument contains wildcards' { + BeforeAll { + # Manifest modules under '~' + # + # Versioned, manifest + $inHomeWithManifestFileName = 'existing' + $inHomeWithManifestDirectory = Join-Path '~' $inHomeWithManifestFileName '0.0.1' + $inHomeWithManifestFilePath = Join-Path $inHomeWithManifestDirectory "$inHomeWithManifestFileName.psm1" + New-Item -ItemType File -Force $inHomeWithManifestFilePath > $null + New-ModuleManifest -Path (Join-Path $inHomeWithManifestDirectory "$inHomeWithManifestFileName.psd1") + # + # Versioned, manifest + $inHomeWithManifestFileName2 = 'existing2' + $inHomeWithManifestDirectory2 = Join-Path '~' $inHomeWithManifestFileName2 '0.0.1' + $inHomeWithManifestFilePath2 = Join-Path $inHomeWithManifestDirectory2 "$inHomeWithManifestFileName2.psm1" + New-Item -ItemType File -Force $inHomeWithManifestFilePath2 > $null + New-ModuleManifest -Path (Join-Path $inHomeWithManifestDirectory2 "$inHomeWithManifestFileName2.psd1") + + # Script modules under '~' + # + $inHomeLooseFilePath = Join-Path '~' 'loose.psm1' + New-Item -ItemType File -Force $inHomeLooseFilePath > $null + } + + AfterAll { + Remove-Item -Force -Recurse $inHomeWithManifestDirectory + Remove-Item -Force -Recurse $inHomeWithManifestDirectory2 + + Remove-Item $inHomeLooseFilePath + } } } From 2c5886498deb975b598b08f626b9c65418438bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:34:58 +0200 Subject: [PATCH 54/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 93f88ac15c2..162cd8d96a3 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -382,6 +382,15 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Remove-Item $inHomeLooseFilePath } + + It 'returns existing manifest modules when using the -Name parameter' { + $name = Join-Path ~ existing* + + $actual = Get-Module -ListAvailable -Name $name + $actual | Should -HaveCount 2 + $actual[0].Path | Should -BeExactly (Join-Path $HOME existing 0.0.1, existing.psd1) + $actual[1].Path | Should -BeExactly (Join-Path $HOME existing2 0.0.1, existing2.psd1) + } } } From e4e16964098bd25fbc1f13c0d8bcf8ff1db14918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:35:06 +0200 Subject: [PATCH 55/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 162cd8d96a3..a3cc17e2ea0 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -391,6 +391,12 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual[0].Path | Should -BeExactly (Join-Path $HOME existing 0.0.1, existing.psd1) $actual[1].Path | Should -BeExactly (Join-Path $HOME existing2 0.0.1, existing2.psd1) } + + # TODO: This looks like a bug. + It 'wrongly returns $null for existing manifest modules when using the -FullyQualifiedName parameter' { + $actual = Get-Module -ListAvailable -FullyQualifiedName (Join-Path ~ existing*) + $actual | Should -Be $null + } } } From 0bb5dda192135d96cae4e88d46734a05ca031731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:35:10 +0200 Subject: [PATCH 56/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index a3cc17e2ea0..d979099dc47 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -397,6 +397,12 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual = Get-Module -ListAvailable -FullyQualifiedName (Join-Path ~ existing*) $actual | Should -Be $null } + + It 'returns module information for existing script module' { + $actual = Get-Module -ListAvailable -Name (Join-Path ~ loose*) + $actual | Should -HaveCount 1 + $actual[0].Path | Should -BeExactly (Join-Path $HOME loose.psm1) + } } } From c6bdcf8e92910873c26aeda3335e4a199de59c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:42:39 +0200 Subject: [PATCH 57/82] Add `Describe` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index d979099dc47..40462d6a00a 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -280,6 +280,9 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { } } +Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is module name or filename-like' -Tags "CI" { +} + Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is home-rooted' -Tags "CI" { It 'wrongly does not expand ''~'' to $HOME' { $path = Join-Path ~ missing.psm1 From 056942776f8a98da9c7d676b703330267a319683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:43:07 +0200 Subject: [PATCH 58/82] Add test --- .../Get-Module.Tests.ps1 | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 40462d6a00a..3653b285bcc 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -281,6 +281,88 @@ Describe "Get-Module -ListAvailable" -Tags "CI" { } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is module name or filename-like' -Tags "CI" { + BeforeAll { + $oldPSModulePath = $env:PSModulePath + $env:PSModulePath = New-Item -ItemType Directory (Join-Path $TestDrive modules) + + # Manifest modules under $env:PSModulePath + # + # Versioned, manifest + $inPSModulePathWithManifestFileName = 'existing' + $inPSModulePatWithManifestDirectory = Join-Path $env:PSModulePath $inPSModulePathWithManifestFileName '0.0.1' + $inPSModulePathWithManifestFilePath = Join-Path $inPSModulePatWithManifestDirectory "$inPSModulePathWithManifestFileName.psm1" + New-Item -ItemType File -Force $inPSModulePathWithManifestFilePath > $null + New-ModuleManifest -Path (Join-Path $inPSModulePatWithManifestDirectory "$inPSModulePathWithManifestFileName.psd1") + # + # Versioned, manifest + $inPSModulePathWithManifestFileName2 = 'existing2' + $inPSModulePatWithManifestDirectory2 = Join-Path $env:PSModulePath $inPSModulePathWithManifestFileName2 '0.0.1' + $inPSModulePathWithManifestFilePath2 = Join-Path $inPSModulePatWithManifestDirectory2 "$inPSModulePathWithManifestFileName2.psm1" + New-Item -ItemType File -Force $inPSModulePathWithManifestFilePath2 > $null + New-ModuleManifest -Path (Join-Path $inPSModulePatWithManifestDirectory2 "$inPSModulePathWithManifestFileName2.psd1") + # + # Versioned, manifest, multiple components in name + $inPSModulePathWithManifestWithPathLikeNameFileName = 'existing.xxx' + $inPsModulePathWithManifestWithPathLikeNameDirectory = Join-Path $env:PSModulePath $inPSModulePathWithManifestWithPathLikeNameFileName '0.0.1' + $inPsModulePathWithManifestWithPathLikeNameFilePath = Join-Path $inPsModulePathWithManifestWithPathLikeNameDirectory "$inPSModulePathWithManifestWithPathLikeNameFileName.psm1" + New-Item -ItemType File -Force $inPsModulePathWithManifestWithPathLikeNameFilePath > $null + New-ModuleManifest -Path (Join-Path $inPsModulePathWithManifestWithPathLikeNameDirectory "$inPSModulePathWithManifestWithPathLikeNameFileName.psd1") + # + # Versioned, manifest, multiple components in name, name ending with PS module extension + $inPSModulePathWithManifestWithPathLikeNameAsPSExtensionFileName = 'existing.psm1' + $inPSModulePathWithManifestWithPathLikeNameAsPSExtensionDirectory = Join-Path $env:PSModulePath $inPSModulePathWithManifestWithPathLikeNameAsPSExtensionFileName '0.0.1' + $inPSModulePathWithManifestWithPathLikeNameAsPSExtensionFilePath = Join-Path $inPSModulePathWithManifestWithPathLikeNameAsPSExtensionDirectory "$inPSModulePathWithManifestWithPathLikeNameAsPSExtensionFileName.psm1" + New-Item -ItemType File -Force $inPSModulePathWithManifestWithPathLikeNameAsPSExtensionFilePath > $null + New-ModuleManifest -Path (Join-Path $inPSModulePathWithManifestWithPathLikeNameAsPSExtensionDirectory "$inPSModulePathWithManifestWithPathLikeNameAsPSExtensionFileName.psd1") + + # Script modules + # + # Under $env:PSModulePath. TODO: Is this a supported scenario? + $inPSModulePathLooseFilePath = Join-Path $env:PSModulePath 'existing-loose.psm1' + New-Item -ItemType File -Force $inPSModulePathLooseFilePath > $null + # + # Under $env:PSModulePath, multiple components in name. TODO: Is this a supported scenario? + $inPSModulePathLooseWithPathLikeFilePath = Join-Path $env:PSModulePath "existing-loose.xxx.psm1" + New-Item -ItemType File -Force $inPSModulePathLooseWithPathLikeFilePath > $null + # + # Under $env:PSModulePath, multiple components in name, name ending with PS module extension. TODO: Is this a supported scenario? + $inPSModulePathLooseWithPathLikeNameAsPSExtensionFilePath = Join-Path $env:PSModulePath "existing.psm1.psm1" + New-Item -ItemType File -Force $inPSModulePathLooseWithPathLikeNameAsPSExtensionFilePath > $null + # + # In working directory + $inWorkingDirectoryLooseFilePath = Join-Path . existing.psm1 + New-Item -ItemType File -Force $inWorkingDirectoryLooseFilePath > $null + # + # In parent directory + $inParentDirectoryLooseFilePath = Join-Path .. existing.psm1 + New-Item -ItemType File -Force $inParentDirectoryLooseFilePath > $null + # + # In working directory, ignored + 'function foo { "_" }' > (Join-Path $pwd ignore.psm1) + 'function foo { "_" }' > (Join-Path $pwd ignore.psm1.psm1) + } + + AfterAll { + $env:PSModulePath = $oldPSModulePath + + Remove-Item -ErrorAction Stop -Force -Recurse $inPSModulePatWithManifestDirectory + Remove-Item -ErrorAction Stop -Force -Recurse $inPSModulePatWithManifestDirectory2 + Remove-Item -ErrorAction Stop -Force -Recurse $inPsModulePathWithManifestWithPathLikeNameDirectory + Remove-Item -ErrorAction Stop -Force -Recurse $inPSModulePathWithManifestWithPathLikeNameAsPSExtensionDirectory + + Remove-Item -ErrorAction Stop $inPSModulePathLooseFilePath + Remove-Item -ErrorAction Stop $inPSModulePathLooseWithPathLikeFilePath + Remove-Item -ErrorAction Stop $inPSModulePathLooseWithPathLikeNameAsPSExtensionFilePath + Remove-Item -ErrorAction Stop $inWorkingDirectoryLooseFilePath + Remove-Item -ErrorAction Stop $inParentDirectoryLooseFilePath + Remove-Item -ErrorAction Stop ignore.psm1 + Remove-Item -ErrorAction Stop ignore.psm1.psm1 + } + + It 'returns module information for manifest module' { + Get-Module -ListAvailable -FullyQualifiedName existing | ForEach-Object Path | Should -BeExactly (Join-Path $env:PSModulePath existing '0.0.1','existing.psd1') + Get-Module -ListAvailable -Name existing | ForEach-Object Path | Should -BeExactly (Join-Path $env:PSModulePath existing '0.0.1','existing.psd1') + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is home-rooted' -Tags "CI" { From 7bbd2b62d00227e69d20165758131de94687b8cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:43:12 +0200 Subject: [PATCH 59/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 3653b285bcc..27b3946fa68 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -363,6 +363,11 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Get-Module -ListAvailable -FullyQualifiedName existing | ForEach-Object Path | Should -BeExactly (Join-Path $env:PSModulePath existing '0.0.1','existing.psd1') Get-Module -ListAvailable -Name existing | ForEach-Object Path | Should -BeExactly (Join-Path $env:PSModulePath existing '0.0.1','existing.psd1') } + + It 'ignores module at current directory' { + Get-Module -ListAvailable -FullyQualifiedName ignore | Should -Be $null + Get-Module -ListAvailable -Name ignore | Should -Be $null + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is home-rooted' -Tags "CI" { From f2f491e6bf53ad9530f5fb3d79257d8a1cde9573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:43:30 +0200 Subject: [PATCH 60/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 27b3946fa68..cccc0544636 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -368,6 +368,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Get-Module -ListAvailable -FullyQualifiedName ignore | Should -Be $null Get-Module -ListAvailable -Name ignore | Should -Be $null } + + Context 'When path value has PS module extension, such as ''name.psm1''' { + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is home-rooted' -Tags "CI" { From 63e403d351e9adcde1a63875fd1f30c38eca424f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Sun, 9 Aug 2026 21:43:36 +0200 Subject: [PATCH 61/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index cccc0544636..89acf0ac366 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -370,6 +370,11 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'When path value has PS module extension, such as ''name.psm1''' { + # Because non-rooted/non-relative-rooted paths MUST be resolved to modules under $env:PSModulePath. + It 'ignores module at current directory' { + Get-Module -ListAvailable -FullyQualifiedName ignore.psm1 | Should -Be $null + Get-Module -ListAvailable -Name ignore.psm1 | Should -Be $null + } } } From 9bff3f0c9a0a896feef248f5231733e283ab9c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:33:53 +0200 Subject: [PATCH 62/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 89acf0ac366..c340998f517 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -375,6 +375,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Get-Module -ListAvailable -FullyQualifiedName ignore.psm1 | Should -Be $null Get-Module -ListAvailable -Name ignore.psm1 | Should -Be $null } + + Context 'Resolves to module under $env:PSModulePath' { + } } } From bdd49cc1526a398a8bc37c64794c617fd8b4d840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:34:02 +0200 Subject: [PATCH 63/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index c340998f517..7a5e0c3ce90 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -377,6 +377,13 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'Resolves to module under $env:PSModulePath' { + # Unclear whether this is correct behavior. Are loose modules allowed under $env:PSModulePath? + # Could resolve to: + # - 'existing-loose.psm1' loose module + It 'wrongly/correctly returns $null instead of module information for loose module' { + Get-Module -ListAvailable -FullyQualifiedName existing-loose.psm1 | Should -Be $null + Get-Module -ListAvailable -Name existing-loose.psm1 | Should -Be $null + } } } } From a48815cf8270e4770bb42a91118338526d97ccdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:34:10 +0200 Subject: [PATCH 64/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 7a5e0c3ce90..8205f6c0037 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -384,6 +384,14 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Get-Module -ListAvailable -FullyQualifiedName existing-loose.psm1 | Should -Be $null Get-Module -ListAvailable -Name existing-loose.psm1 | Should -Be $null } + + # Unclear whether this is correct behavior. Are loose modules allowed under $env:PSModulePath?. + # Could resolve to: + # - 'existing2' manifest module + It 'wrongly/correctly returns $null instead of module information for versioned module' { + Get-Module -ListAvailable -FullyQualifiedName existing2.psm1 | Should -Be $null + Get-Module -ListAvailable -Name existing2.psm1 | Should -Be $null + } } } } From ebe1ecbf84e51cef8ad014c854414c7507bad7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:34:19 +0200 Subject: [PATCH 65/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 8205f6c0037..770a29b67e4 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -392,6 +392,12 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Get-Module -ListAvailable -FullyQualifiedName existing2.psm1 | Should -Be $null Get-Module -ListAvailable -Name existing2.psm1 | Should -Be $null } + + # Finds manifest module 'existing.psm1.psm1'. TODO: Is that correct? + It 'wrongly/correctly returns module information for versioned module ending with PS extension' { + Get-Module -ListAvailable -FullyQualifiedName existing.psm1 | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + Get-Module -ListAvailable -Name existing.psm1 | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + } } } } From e37c3225ba98b388d88f5d7d623892e801999684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:34:34 +0200 Subject: [PATCH 66/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 770a29b67e4..b26af8a93f5 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -399,6 +399,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Get-Module -ListAvailable -Name existing.psm1 | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) } } + + Context 'Resolves to non-existing loose or versioned module under $env:PSModulePath' { + } } } From d9daa5377b739956e0374fd563461f9d16b29108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:34:41 +0200 Subject: [PATCH 67/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index b26af8a93f5..068ec07a267 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -401,6 +401,15 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'Resolves to non-existing loose or versioned module under $env:PSModulePath' { + It 'wrongly returns $null instead of error' { + $path1 = Join-Path $env:PSModulePath missing.psm1 + $path2 = Join-Path $env:PSModulePath missing.psm1 *, missing.psm1 + Test-Path $path1 | Should -BeFalse + Test-Path $path2 | Should -BeFalse + + Get-Module -ListAvailable -FullyQualifiedName missing.psm1 | Should -Be $null + Get-Module -ListAvailable -Name missing.psm1 | Should -Be $null + } } } } From 963c04dda1caef74ebaf04a43be2d610e3da48ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:34:56 +0200 Subject: [PATCH 68/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 068ec07a267..370efce84d1 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -412,6 +412,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } } } + + Context 'When path value has unknown extension, such as ''name.xxx''' { + } } Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argument is home-rooted' -Tags "CI" { From 8fe048632c8711dc0e7cbfdadd5a6e7b561c9cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:35:14 +0200 Subject: [PATCH 69/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 370efce84d1..54fc1428648 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -414,6 +414,8 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'When path value has unknown extension, such as ''name.xxx''' { + Context 'Resolves to non-existing loose or versioned module under $env:PSModulePath' { + } } } From 47a6d46b5ff1d0422536877102f634731b8d9e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:35:20 +0200 Subject: [PATCH 70/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 54fc1428648..8bd582cf347 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -415,6 +415,15 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Context 'When path value has unknown extension, such as ''name.xxx''' { Context 'Resolves to non-existing loose or versioned module under $env:PSModulePath' { + It 'wrongly returns $null instead of error' { + $path1 = Join-Path $env:PSModulePath missing.xxx.psm1 + $path2 = Join-Path $env:PSModulePath missing *, missing.xxx.psm1 + Test-Path $path1 | Should -BeFalse + Test-Path $path2 | Should -BeFalse + + Get-Module -ListAvailable -FullyQualifiedName missing.xxx | Should -Be $null + Get-Module -ListAvailable -Name missing.xxx | Should -Be $null + } } } } From 47e4bad50bfadfdbd76564f8e587847cb72ea504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:35:28 +0200 Subject: [PATCH 71/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 8bd582cf347..d68d99354e1 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -425,6 +425,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Get-Module -ListAvailable -Name missing.xxx | Should -Be $null } } + + Context 'Resolves to loose module under $env:PSModule' { + } } } From 8f1beaaeaf275f1a84052c5a12a4151a3fd80f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:35:35 +0200 Subject: [PATCH 72/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index d68d99354e1..609707e9e14 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -427,6 +427,13 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'Resolves to loose module under $env:PSModule' { + # Unclear whether only manifest modules are discovered under $env:PSModulePath. + It 'wrongly/correctly returns $null instead of module information' { + $path = Join-Path $env:PSModulePath existing-loose.xxx.psm1 + Test-Path $path | Should -BeTrue + + Get-Module -ListAvailable -FullyQualifiedName existing-loose.xxx | Should -Be $null + } } } } From 3d826dd9522082658875b77a523e20396c8b7018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:35:45 +0200 Subject: [PATCH 73/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 609707e9e14..6206cde8c87 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -435,6 +435,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Get-Module -ListAvailable -FullyQualifiedName existing-loose.xxx | Should -Be $null } } + + Context 'Resolves to manifest module under $env:PSModule' { + } } } From ce944e9f4995d7c117cb4136fe2c72ee7a8393a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 21:35:52 +0200 Subject: [PATCH 74/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 6206cde8c87..bbcccd36c41 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -437,6 +437,14 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'Resolves to manifest module under $env:PSModule' { + # Unclear whether only manifest modules are discovered under $env:PSModulePath. + It 'returns module information' { + $path = Join-Path $env:PSModulePath existing.xxx 0.0.1, existing.xxx.psm1 + Test-Path $path | Should -BeTrue + + Get-Module -ListAvailable -FullyQualifiedName existing.xxx | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + Get-Module -ListAvailable -Name existing.xxx | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) + } } } } From a2062ec5293db27ea79c94e3ef5efd52bcddc028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 22:37:15 +0200 Subject: [PATCH 75/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index bbcccd36c41..43ba11344a6 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -446,6 +446,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum Get-Module -ListAvailable -Name existing.xxx | Should -BeOfType ([System.Management.Automation.PSModuleInfo]) } } + + Context 'When argument has wildcards' { + } } } From 56c561d92c6421c2ce76da2899f34012e03b19e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 22:37:24 +0200 Subject: [PATCH 76/82] Add test --- .../Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 43ba11344a6..b849c306e95 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -448,6 +448,15 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'When argument has wildcards' { + It 'ignores existing script modules in working directory' { + Join-Path $pwd ignore.psm1 | Should -BeTrue + + $actual = Get-Module -ListAvailable -Name ignore* + $actual | Should -Be $null + + $actual = Get-Module -ListAvailable -FullyQualifiedName ignore* + $actual | Should -Be $null + } } } } From d099bf62b4e66cb3aea562212c54d70854147a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 22:37:37 +0200 Subject: [PATCH 77/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index b849c306e95..f3a17e73808 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -457,6 +457,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual = Get-Module -ListAvailable -FullyQualifiedName ignore* $actual | Should -Be $null } + + Context 'Resolves to existing script modules' { + } } } } From 10754158821211f349433b4b1251bd1ffd818071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 22:37:44 +0200 Subject: [PATCH 78/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index f3a17e73808..7ce9e17442a 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -459,6 +459,13 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'Resolves to existing script modules' { + It 'wrongly/correctly returns $null' { + $actual = Get-Module -ListAvailable -Name existing-loose* + $actual | Should -Be $null + + $actual = Get-Module -ListAvailable -FullyQualifiedName existing-loose* + $actual | Should -Be $null + } } } } From b7b3126892fe874fe50525123db9d667e522e44d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 22:37:55 +0200 Subject: [PATCH 79/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 7ce9e17442a..9a2a18d97a6 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -467,6 +467,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual | Should -Be $null } } + + Context 'Resolves to existing manifest modules' { + } } } } From 2b27c51a8af2260e9e8fccbffe3f0817be7e27cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 22:38:02 +0200 Subject: [PATCH 80/82] Add test --- .../Get-Module.Tests.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 9a2a18d97a6..79ca9426077 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -469,6 +469,21 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'Resolves to existing manifest modules' { + It 'returns modules' { + $actual = Get-Module -ListAvailable -Name existing* + $actual | Should -HaveCount 4 + $actual[0].Name | Should -BeExactly existing + $actual[1].Name | Should -BeExactly existing.psm1 + $actual[2].Name | Should -BeExactly existing.xxx + $actual[3].Name | Should -BeExactly existing2 + + $actual = Get-Module -ListAvailable -FullyQualifiedName existing* + $actual | Should -HaveCount 4 + $actual[0].Name | Should -BeExactly existing + $actual[1].Name | Should -BeExactly existing.psm1 + $actual[2].Name | Should -BeExactly existing.xxx + $actual[3].Name | Should -BeExactly existing2 + } } } } From 26957357b13290cb9468ffe0128ba28c406aac4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 22:38:16 +0200 Subject: [PATCH 81/82] Add `Context` --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index 79ca9426077..e79e8579d69 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -485,6 +485,9 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum $actual[3].Name | Should -BeExactly existing2 } } + + Context 'Resolves to non-existing modules' { + } } } } From c8d50419e7a6f5b35c3595c98b6b322b362c07e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20L=C3=B3pez?= Date: Tue, 11 Aug 2026 22:38:23 +0200 Subject: [PATCH 82/82] Add test --- .../Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 index e79e8579d69..e4855255df3 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Module.Tests.ps1 @@ -487,6 +487,13 @@ Describe 'Get-Module -ListAvailable -(FullyQualifiedName|Name) when argum } Context 'Resolves to non-existing modules' { + It 'wrongly/correctly returns $null' { + $actual = Get-Module -ListAvailable -Name missing* + $actual | Should -Be $null + + $actual = Get-Module -ListAvailable -FullyQualifiedName missing* + $actual | Should -Be $null + } } } }