Closed o-l-a-v closed 4 months ago
Not sure if this is what you are looking for but I have always used the following in order to update my modules
Get-Module -ListAvailable | Update-Module -WhatIf*
*obviously running without whatif will actually update the module.
This will only work with Modules that have been installed from the Gallery.
Hope that helps.
@BanterBoy
I only want the version number of the latest released module returned, so that I can handle install with my own logic. Else you get loads of deprecated/ old versions left + no way of controlling what modules not to update etc.
But Update-Module -WhatIf gave me some new info on how to retrieve version info, will check that out, thanks.
VERBOSE: Checking for updates for module 'Az.Accounts'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; 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.Accounts'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'Az.Accounts'.
VERBOSE: Skipping installed module Az.Accounts 1.9.4.
I have this script for updating PowerShell modules, and removing outdated ones.
In it I have following function for getting latest published version of a module from PowerShellGallery
Prerequirement
Function
Earlier this function was wicked fast, now it takes several seconds to complete for each of my installed 300+ modules.