Skip to content

Update and Install-Module Removes Custom PSModulePaths from Current Scope #9845

@ghost

Description

When you set custom PSModulePaths and then run update-module or install-module for modules, even if they weren't installed through PSGallery, the custom module paths are unloaded from the current scope.

Also, Modules that were installed from PSGallery are not updated, regardless if they are in the default or custom Module paths.

This was tested with the AzureAD module. Closing the current PoSH Window and re-opening reloads all PSModulePaths (even custom ones).

Steps to reproduce

Install-Module <ModuleName>

or

Update-Module <ModuleName>

Expected behavior

Install module if it is available from the repository and not unload PSModulePath that aren't default.

Update module that was installed from repository and not unload PSModulePath that aren't default.

Actual behavior

Installs the module requested and then unloads the custom module paths set for the $Env:PSModulePath

Fails to Update the module (even ones installed from repository) and then unloads the custom module paths set for $Env:PSModulePath

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0-preview.1
PSEdition                      Core
GitCommitId                    7.0.0-preview.1
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-PowerShellGetspecific to PowerShellGet moduleIssue-BugIssue has been identified as a bug in the productResolution-ExternalThe issue is caused by external component(s).WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions