Install-Module is duplicating Entries

Hello,

When I install any module from the PSGallery such as Get-Module xExchange, or XPSReboot, PowerShellCookBook, etc, the show up twice and I don’t know why.

If I view the properties both entries are 100% identical (used compare object)

This is causing issues when trying to use a DSC resource because it tells me there are multiple version and it wants me to declare the version, however both version are the same.

Windows 10 Build 14257.rs1
v5.0.14257.1000

What do you get when you run this? Get-Module xExchange -ListAvailable

It’s been awhile so wanted to get this issue resolved. Here is the output. Its very annoying even if I delete and then re-run it keeps thinking there are two when there is clearly only 1 and they are the same.

Find-Module xExchange | Install-Module

Module Path
C:\Program Files\WindowsPowerShell\Modules\xExchange\1.6.0.0

Multple versions of the module ‘xExchange’ were found. You can run ‘Get-Module -ListAvaliable -FullyQualifiedName xExchange’ to see available versionf on the system, and then use fully qualified name ‘@{ModuleName=“xExchange”; RequiredVersion="Version’}'.

PS C:> Get-Module -ListAvailable -FullyQualifiedName xExchange | Select Name,Version,modulebase

Name Version ModuleBase


xExchange 1.6.0.0 C:\Program Files\WindowsPowerShell\Modules\xExchange\1.6.0.0
xExchange 1.6.0.0 C:\Program Files\WindowsPowerShell\Modules\xExchange\1.6.0.0

There have been some similar emails on the MVP list lately, and we think it’s due to duplicate entries in the PSModulePath variable, along with PowerShell not properly normalizing and deduplicating those paths.

I believe this will be fixed in a future release of PowerShell, but in the meantime, what’s in your $env:PSModulePath ?

Thanks Dave. Had the same issue. Turned out the ModulePath was listed more than once in $env:PSModulePath.

Any further word on this? It’s been happening to me on several servers. When it does and I try to apply a DSC config, it errors out because it’s finding the modules too many times.

What’s worse is that I know I have fixed this by manually editing the path, but the problem came back. I don’t know what’s putting it back, unless it’s something from a Windows Update.