Script for updating all AZ PowerShell Modules at once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://robertsmit.wordpress.com/2020/05/27/update-all-az-azure-powershell-modules-powershell-azure-script-modules/ | |
# Author: Robert Smit | |
Get-Module -Name az.* -ListAvailable | | |
Where-Object -Property Name -ne 'Az.' | | |
ForEach-Object { | |
$currentVersion = [Version] $_.Version | |
$newVersion = [Version] (Find-Module -Name $_.Name).Version | |
if ($newVersion -gt $currentVersion) { | |
Write-Host -Object "Updating $_ Module from $currentVersion to $newVersion" | |
Update-Module -Name $_.Name -RequiredVersion $newVersion -Force | |
Uninstall-Module -Name $_.Name -RequiredVersion $currentVersion -Force | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment