You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
This behavior impacts any Powershell Core installation that requires modules to be installed at the system-specific path for Service Account or SYSTEM to consume them. If the preference is to use user-path, so be it but there should be a way (such as support Scope param) to force it otherwise.
Steps to reproduce
In an elevated powershell core window, choose a module from system path (not user path) and issue Update-Module for it:
PS C:\Users\Leandro>$env:PSModulePath
C:\Users\Leandro\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\windowspowershellcore\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PS C:\Users\Leandro> Gci "C:\Program Files\PowerShell\Modules\Az.Automation"
Directory: C:\Program Files\PowerShell\Modules\Az.Automation
Mode LastWriteTime Length Name
---------------------------
d-----17/02/201921:251.1.0
d-----08/03/201922:551.1.1
d-----06/04/201911:241.2.0
PS C:\Users\Leandro>update-module AZ.Automation -verbose
VERBOSE: Checking for updates for module 'Az.Automation'.
VERBOSE: Repository details, Name ='PSGallery', Location ='https://www.powershellgallery.com/api/v2/'; IsTrusted ='True'; IsRegistered ='True'.
VERBOSE: Using the provider 'PowerShellGet'for searching packages.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Az.Automation''for''.
VERBOSE: Total package yield:'1'for the specified package 'Az.Automation'.
VERBOSE: Performing the operation "Update-Module" on target "Version '1.2.0' ofmodule 'Az.Automation', updating to version '1.2.1'".
VERBOSE: The installation scope is specified to be 'CurrentUser'.
VERBOSE: The specified module will be installed in'C:\Users\Leandro\Documents\PowerShell\Modules'.
VERBOSE: An update for the module 'Az.Automation' was found with version '1.2.1'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'Az.Automation' with version '1.2.1'from the repository 'https://www.powershellgallery.com/api/v2/'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Az.Automation''for''.
VERBOSE: Package 'Az.Accounts' is already installed.
VERBOSE: Package 'Az.Accounts' is already installed.
VERBOSE: InstallPackage' - name='Az.Automation', version='1.2.1',destination='C:\Users\Leandro\AppData\Local\Temp\1176232375'VERBOSE: DownloadPackage'- name='Az.Automation', version='1.2.1',destination='C:\Users\Leandro\AppData\Local\Temp\1176232375\Az.Automation.1.2.1\Az.Automation.1.2.1.nupkg', uri='https://www.powershellgallery.com/api/v2/package/Az.Automation/1.2.1'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/Az.Automation/1.2.1'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/Az.Automation/1.2.1'.
VERBOSE: Completed downloading 'Az.Automation'.
VERBOSE: InstallPackageLocal' - name='Az.Automation', version='1.2.1',destination='C:\Users\Leandro\AppData\Local\Temp\1176232375'VERBOSE: Validating the 'Az.Automation' module contents under 'C:\Users\Leandro\AppData\Local\Temp\1176232375\Az.Automation.1.2.1' path.VERBOSE: Test-ModuleManifest successfully validated the module manifest file 'C:\Users\Leandro\AppData\Local\Temp\1176232375\Az.Automation.1.2.1'.VERBOSE: Validating the authenticode signature and publisher of the catalog file or module manifest file of the module 'Az.Automation'.VERBOSE: Catalog file 'Az.Automation.cat' is not found in the contents of the module 'Az.Automation' being installed.VERBOSE: For publisher validation, current module 'Az.Automation' with version '1.2.1' with publisher name '' from root certificate authority ''. Is this module signed by Microsoft: 'False'.VERBOSE: For publisher validation, using the previously-installed module 'Az.Automation' with version '1.2.0' under 'C:\Program Files\PowerShell\Modules\Az.Automation\1.2.0' with publisher name '' from root certificate authority ''. Is this module signed by Microsoft: 'False'.VERBOSE: Checking for possible command collisions for the module 'Az.Automation' commands.VERBOSE: Module 'Az.Automation' was installed successfully to path 'C:\Users\Leandro\Documents\PowerShell\Modules\Az.Automation\1.2.1'.PS C:\Users\Leandro> Gci "C:\Program Files\PowerShell\Modules\Az.Automation" Directory: C:\Program Files\PowerShell\Modules\Az.AutomationMode LastWriteTime Length Name---- ------------- ------ ----d----- 17/02/2019 21:25 1.1.0d----- 08/03/2019 22:55 1.1.1d----- 06/04/2019 11:24 1.2.0PS C:\Users\Leandro> gci "C:\Users\Leandro\Documents\PowerShell\Modules\Az.Automation" Directory: C:\Users\Leandro\Documents\PowerShell\Modules\Az.AutomationMode LastWriteTime Length Name---- ------------- ------ ----d----- 26/04/2019 22:30 1.2.1PS C:\Users\Leandro>
Expected behavior
Module should be placed in the system path (in my example "C:\Program Files\PowerShell\Modules\Az.Automation")
Actual behavior
Module was placed in the user path (in my example "C:\Users\Leandro\Documents\PowerShell\Modules\Az.Automation"
The text was updated successfully, but these errors were encountered:
This was a deliberate change in behavior to make Update-Module more consistent with Install-Module, which also defaults to CurrentUser. But I can see the argument for having an explicit -Scope option to override it. Will get to it when I can, or always happy to consider PRs ;-)
I submitted issue #9482 at PowerShell Core repo but I was redirected to submit it here as it's a PowerShellGet issue instead of PS Core.
Latest version of PSGet is always placing modules in user-specific path instead of system-path. Issue seems to be this function:
https://github.com/PowerShell/PowerShellGet/blob/6926ad42e61fc54c5f5b1cdc9e9d8dfceccc2c80/src/PowerShellGet/private/functions/Get-InstallationScope.ps1#L5
This behavior impacts any Powershell Core installation that requires modules to be installed at the system-specific path for Service Account or SYSTEM to consume them. If the preference is to use user-path, so be it but there should be a way (such as support Scope param) to force it otherwise.
Steps to reproduce
In an elevated powershell core window, choose a module from system path (not user path) and issue Update-Module for it:
Expected behavior
Actual behavior
The text was updated successfully, but these errors were encountered: