Skip to content

Instantly share code, notes, and snippets.

@PlagueHO
Last active July 19, 2019 01:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PlagueHO/659e651115d06ec3b64688e58ded01ef to your computer and use it in GitHub Desktop.
Save PlagueHO/659e651115d06ec3b64688e58ded01ef to your computer and use it in GitHub Desktop.
Update all Azure PowerShell modules safely
Get-Module -Name azure* -ListAvailable |
Where-Object -Property Name -ne 'AzureRM' |
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