Module available but not reported as installed

Viewed 1970

Using PowerShell (version 5.1.17134.228), found some unexpected differences between Get-Module and Get-InstalledModule, in that some modules that I'd expect to be returned by Get-InstalledModule are not.

As an example:

Get-Module -ListAvailable -Name 'Hyper-V'

Get-InstalledModule -Name 'Hyper-V'

Output:

PS C:\> Get-Module -ListAvailable -Name 'Hyper-V'


    Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules


ModuleType Version    Name      ExportedCommands
---------- -------    ----      ----------------
Binary     2.0.0.0    Hyper-V   {Add-VMAssignableDevice, Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMGpuPartitionAdapter...}
Binary     1.1        Hyper-V   {Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMHardDiskDrive, Add-VMMigrationNetwork...}


PS C:\> Get-InstalledModule -Name 'Hyper-V'
PackageManagement\Get-Package : No match was found for the specified search
criteria and module names 'Hyper-V'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.6.5\PSModule.psm1:9125 char:9
+         PackageManagement\Get-Package @PSBoundParameters | Microsoft. ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...lets.GetPackage:GetPackage) [Get-Package], Exception
    + FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage

As you can see, the Get-Module command is returning a local path of the Hyper-V modules, so it's definitely installed locally, but Get-InstalledModule cannot find the module.

Is this a bug or have I misunderstood what Get-InstalledModule is meant to do?

0 Answers
Related