If you do a lot with Azure and PowerShell you may noticed that the latest module is important. as functions may not be there or properties are not listed correctly.
There are plenty of scripts around on how to update these modules.
With the Get-InstalledModule you will get a list of the modules on your system
When doing get module with the –listAvailable you will see all the versions
Get-Module -Name az.* -ListAvailable
here is the powershell code Like I said before there are tons of the same scripts around on github or blog post. So don’t invent the wheel again reuse and modify to your needs
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
}
}
Running this can tike some time as you can see In this case I have a lot of old and new modules and these are being updated to the latest versions
When updating this I had some PowerShell windows still open and got some errors, you can also do this by hand.
For sample – Install-Module -Name Az.Accounts -RequiredVersion 1.8.0 –Force
Hope this helps you to a better Azure PowerShell experience.
Follow Me on Twitter @ClusterMVP
Follow My blog https://robertsmit.wordpress.com
Linkedin Profile Robert Smit MVP Linkedin profile
Google : Robert Smit MVP profile