This repository was archived by the owner on Jun 13, 2024. It is now read-only.
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
Update-Module doesn't check all modules when not elevated #78
Closed
Description
When a user runs Update-Module
from a non-elevated host, it only checks modules in the -Scope CurrentUser
folder (i.e. in your Documents\WindowsPowerShell\Modules
, not the Program Files
folder).
This means that there's no built-in way for a (non-elevated) user to even check that all of their modules are up to date.
Expected Behavior
Even when running in a non-elevated host, Update-Module
should check all modules for updates, even though it cannot install them:
> Get-InstalledModule | ft Name, InstalledLocation
Name InstalledLocation
---- -----------------
PackageManagement C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.1.1.0
Pester C:\Program Files\WindowsPowerShell\Modules\Pester\3.4.3
PowerShellGet C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.1.1.0
PSScriptAnalyzer C:\Users\Joel\OneDrive\Documents\WindowsPowerShell\Modules\PSScriptAnalyzer\1.7.0
> Update-Module -WhatIf
What if: Performing the operation "Update-Module" on target "Version '1.1.1.0' of module 'PowerShellGet', updating to version '1.1.2.0'".
What if: Performing the operation "Update-Module" on target "Version '1.7.0' of module 'PSScriptAnalyzer', updating to version '1.9.0'".
> Update-Module
WARNING: Skipped performing Update-Module on target "Version '1.1.1.0' of module 'PowerShellGet', to version '1.1.2.0'" because it's installed in the LocalMachine scope, which requires elevation.
Current Behavior
Currently, PowerShellGet doesn't even let you know that it's not bothering to check:
> Update-Module -WhatIf
What if: Performing the operation "Update-Module" on target "Version '1.7.0' of module 'PSScriptAnalyzer', updating to version '1.9.0'".
> foreach($module in Get-InstalledModule) {
Find-Module -Name $module.Name -Repository $module.Repository -MinimumVersion $module.Version | Where Version -ne $module.Version
}
Version Name Repository Description
------- ---- ---------- -----------
1.9.0 PSScriptAnalyzer PSGallery PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the w...
1.1.2.0 PowerShellGet PSGallery PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifa...
Steps to Reproduce (for bugs)
In an elevated host:
- Use Install-Module to install a specific (older) version of a module to
-Scope CurrentUser
- Use Install-Module to install a specific (older) version of a module to
-Scope AllUser
- Use
Update-Module -Whatif
to verify that it detects both of them are out of date.
In a non-elevated host:
- Use
Update-Module -Whatif
to verify that it only detects one of them. - Use
Update-Module
to verify that it really updates only that one module. - Use
Update-Module -Whatif
to see that it looks like there are no modules in need of updates. - Use the following script to see that the other modules does need updates:
foreach($module in Get-InstalledModule) {
Find-Module -Name $module.Name -Repository $module.Repository -MinimumVersion $module.Version | Where Version -ne $module.Version
}
In an elevated host:
- Use
Update-Module -Whatif
to verify that it detects the module needing updates. - Use
Update-Module
to update it.