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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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/56] 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) + } } }