'How to update all Azure Powershell Az modules?
The Azure Powershell Az module comes with an assortment of modules such as Az.Accounts, Az.Aks, etc. Is it possible to update all these Az.* modules at once?
Solution 1:[1]
Try this
Get-InstalledModule -Name Az* | Update-Module
You can add -Force
after Update-Module
, so you won't be prompted with stuff like an untrusted repository every single module.
Solution 2:[2]
Update-Module Az -Force
All the individual modules are dependencies of the Az module. So this should do the trick.
Add -Verbose if you want to track progress.
Solution 3:[3]
This article provides complete detailed information and steps on e Azure Az PowerShell module: https://docs.microsoft.com/en-us/powershell/azure/new-azureps-module-az?view=azps-5.7.0 If you are looking for specific service module check in the reference section
Solution 4:[4]
You could try this script, which I wrote a while ago. It goes through every Az.*
module and updates to the latest version, including removing previous versions that are still installed.
# Go through all Az.* versions
# Use -ListAvailable to show all versions
Get-Module -Name Az.* -ListAvailable | ForEach-Object {
$moduleName = $_.Name
$currentVersion = [Version]$_.Version
Write-Host "Current version $moduleName [$currentVersion]"
# Get latest version from gallery
$latestVersion = [Version](Find-Module -Name $moduleName).Version
# Only proceed if latest version in gallery is greater than your current version
if ($latestVersion -gt $currentVersion) {
Write-Host "Found latest version $modulename [$latestVersion] from $($latestVersionModule.Repository)"
# Check if latest version is already installed before updating
$latestVersionModule = Get-InstalledModule -Name $moduleName -RequiredVersion $latestVersion -ErrorAction SilentlyContinue
if ($null -eq $latestVersionModule) {
Write-Host "Updating $moduleName Module from [$currentVersion] to [$latestVersion]"
Update-Module -Name $moduleName -RequiredVersion $latestVersion -Force
}
else {
Write-Host "No update needed, $modulename [$latestVersion] already exists"
}
# Uninstall outdated version
Write-Host "Uninstalling $moduleName [$currentVersion]"
Uninstall-Module -Name $moduleName -RequiredVersion $currentVersion -Force
}
# Otherwise we already have most up to date version
else {
Write-Host "$moduleName already up to date"
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | |
Solution 3 | SumanthMarigowda-MSFT |
Solution 4 | RoadRunner |