-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Get-Module -ListAvailable hides edition-incompatible modules but lists otherwise incompatible modules #7298
Description
Get-Module -ListAvailable will list modules with badly formatted manifests or that have unmet requirements, but will not list modules that have incompatible PSEditions (as per the RFC).
Get-Module -ListAvailable should be consistent about whether modules that can be loaded in a current session can be listed.
Here's a small repro for an unloadable module that is still listed by Get-Module -ListAvailable:
> New-Item -Path $PowerShellDevDir\src\powershell-win-core\bin\Debug\netcoreapp2.1\win7-x64\publish\Modules\BADMODULE -Value "Banana"
> Get-Module -ListAvailable
...
Directory:
C:\users\roholt\documents\dev\powershell\src\powershell-win-core\bin\debug\netcoreapp2.1\win7-x64\publish\Modules
ModuleType Version Name PSEdition ExportedCommands
---------- ------- ---- --------- ----------------
Manifest 6.1.0.0 CimCmdlets Core {Get-CimAssociatedInstance, Get-CimClass, Get-CimInst...
Script 0.0 LocalUnsignedModule Desk
Script 0.0 LocalUntrustedModule Desk
Manifest 1.1.0.0 Microsoft.PowerShell.Archive Desk {Compress-Archive, Expand-Archive}
Manifest 6.1.0.0 Microsoft.PowerShell.Diagnostics Core {Get-WinEvent, New-WinEvent}
Manifest 6.1.0.0 Microsoft.PowerShell.Host Core {Start-Transcript, Stop-Transcript}
Manifest 6.1.0.0 Microsoft.PowerShell.Management Core {Add-Content, Clear-Content, Clear-ItemProperty, Join...
Manifest 6.1.0.0 Microsoft.PowerShell.Security Core {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...
Manifest 6.1.0.0 Microsoft.PowerShell.Utility Core {Format-List, Format-Custom, Format-Table, Format-Wid...
Manifest 6.1.0.0 Microsoft.WSMan.Management Core {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSMan...
Manifest 0.0 BADMODULE Desk
Script 1.1.7.0 PackageManagement Desk {Find-Package, Get-Package, Get-PackageProvider, Get-...
Script 4.2.0 Pester Desk {Describe, Context, It, Should...}
Script 1.6.0 PowerShellGet Desk {Install-Module, Find-Module, Save-Module, Update-Mod...
Script 0.0 PSDesiredStateConfiguration Desk {Test-ModuleReloadRequired, ConvertTo-MOFInstance, In...
Script 6.1.0.0 PSDiagnostics Core {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disab...
Script 2.0.0 PSReadLine Desk {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, ...
Binary 1.1.1 ThreadJob Desk Start-ThreadJob
Essentially, you can write a nonsense module in a file with the right extension, and if it's on the module path, it will be displayed by Get-Module -ListAvailable. But a psd1 that is correct but does not list "Core" under "CompatiblePSEditions" will not be displayed.
A consequence of this is that if a module is not compatible with the current PSEdition and loaded from the System32 module path, but has another error in it that causes the manifest processing to fail earlier, the module will be listed when the CompatiblePSEditions RFC says it should not be.
One proposal might be, either:
Get-Module -ListAvailablereturns a list of all files that are plausibly PowerShell modules (including those incompatible with the current PSEdition), ORGet-Module -ListAvailabledoes not list modules that are unable to be loaded in the current PowerShell session (this would be a more significant breaking change).
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-preview.3
PSEdition Core
GitCommitId v6.1.0-preview.3-161-g6d72598bde08ca2507cd357b5723204ec4941541
OS Microsoft Windows 10.0.17713
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0