Powershell: Get-Module -ListAvailable skips module found in PSModulePath

Created on 25 Oct 2018  路  4Comments  路  Source: PowerShell/PowerShell

Installing the Az module from the PowerShell Gallery will install the base Az module, as well as all other submodules (_e.g._, Az.Compute, Az.Sql, etc.) that it requires -- however, this module appears to be skipped when running Get-Module -ListAvailable, whereas all of the submodules appear.

Steps to reproduce

> Install-Module -Name Az -Repository PSGallery -Force

> Get-Module -Name Az -ListAvailable

Expected behavior

> Get-Module -Name Az -ListAvailable


    Directory: C:\Program Files\PowerShell\Modules


ModuleType Version    Name                                PSEdition ExportedCommands
---------- -------    ----                                --------- ----------------
Script     0.4.0      Az                                  Core,Desk 

>

Actual behavior

> Get-Module -Name Az -ListAvailable
>

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0
PSEdition                      Core
GitCommitId                    6.1.0
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue-Bug Resolution-Fixed WG-Engine

Most helpful comment

Looked into the code, and this is because Az is a valid culture and powershell believes its a local directory just like en and skipped it ...
c# LCID Name DisplayName ---- ---- ----------- 44 az Azerbaijani
https://github.com/PowerShell/PowerShell/blob/ddaad12183112d6fd28bedadff7761c630e71d5b/src/System.Management.Automation/engine/Modules/ModuleUtils.cs#L46-L59

All 4 comments

@rjmholt for comment.

Looked into the code, and this is because Az is a valid culture and powershell believes its a local directory just like en and skipped it ...
c# LCID Name DisplayName ---- ---- ----------- 44 az Azerbaijani
https://github.com/PowerShell/PowerShell/blob/ddaad12183112d6fd28bedadff7761c630e71d5b/src/System.Management.Automation/engine/Modules/ModuleUtils.cs#L46-L59

Wow, what's the situation this is intended to avoid? Is there an extra check we can do, like check if the dirname matches the module name?

@rjmholt looks like an optimization with the assumption that directories named after locales don't contain modules. Perhaps we can just remove that bit of code and see what the perf difference is.

Was this page helpful?
0 / 5 - 0 ratings