Skip to content

Instantly share code, notes, and snippets.

@cloudchristoph
Created May 28, 2020 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloudchristoph/8bdb6d21a60bbc20e8819b94b887dcdc to your computer and use it in GitHub Desktop.
Save cloudchristoph/8bdb6d21a60bbc20e8819b94b887dcdc to your computer and use it in GitHub Desktop.
Script for updating all AZ PowerShell Modules at once
# 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