mark
mark

Reputation: 62886

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

Please, observe:

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 ≡]>

Anyone?

EDIT 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:\>

Upvotes: 1

Views: 135

Answers (1)

mklement0
mklement0

Reputation: 440337

To summarize the helpful information provided by Lee_Dailey and Owain Esau in the comments:

  • Get-Module -ListAvailable lists all modules available in standard locations - irrespective of whether these modules are currently loaded or not.

    • These 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 for details.
  • Get-Module by itself lists all currently loaded modules.

It follows that Get-Module -ListAvailable is not a true superset of Get-Module in that it doesn't list those among the currently loaded modules that were loaded from nonstandard locations; to quote the 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.

Upvotes: 1

Related Questions