为什么 Get-Module X 显示了一些东西,但 Get-Module X -ListAvailable 却没有?

How come Get-Module X shows something, but Get-Module X -ListAvailable does not?

请注意:

C:\xyz\DevOps\DFDeploymentSmokeTests [master ≡]> get-module xyz.PS.Dev -ListAvailable | ft -AutoSize
C:\xyz\DevOps\DFDeploymentSmokeTests [master ≡]> get-module xyz.PS.Dev | ft -AutoSize

ModuleType Version     Name            ExportedCommands
---------- -------     ----            ----------------
Manifest   1.0.19107.2 xyz.PS.Dev {Add-OctopusChannelsToProjectSteps, Add-OctopusEnvironmentsToProjectSteps, Add-VisualStudioToPath, Copy-OctopusVariables...}


C:\xyz\DevOps\DFDeploymentSmokeTests [master ≡]>

有人吗?

编辑 1

C:\> Get-Help Get-Module -Parameter ListAvailable

-ListAvailable

    Required?                    true
    Position?                    Named
    Accept pipeline input?       false
    Parameter set name           Available, PsSession, CimSession
    Aliases                      None
    Dynamic?                     false    

C:\>

总结 Lee_Dailey and Owain Esau 在评论中提供的有用信息:

  • Get-Module -ListAvailable 列出 可用 标准位置 中的所有模块 - 无论这些模块当前是否可用是否加载。

    • 这些 standard locations are the directories listed in the $env:PSModulePath environment variable that PowerShell either creates on demand or adds missing entries to; modules located in these directories are loaded automatically, on demand when their commands are accessed, assuming the $PSModuleAutoLoadingPreference is unset (the default); see the docs 了解详情。
  • Get-Module 本身列出了所有 当前加载的模块 .

因此 Get-Module -ListAvailable 不是 Get-Module 的真正超集,因为它没有列出当前加载的模块中那些从 [=31= 加载的模块]非标准位置;引用 Get-Module help:

ListAvailable does not return information about modules that are not found in the PSModulePath environment variable, even if those modules are loaded in the current session.