Reputation: 3281
I am trying to install Module 'Azure' for powershell.
When I fire this
Install-Module 'Azure'
I Get the error message "WARNING: Version '4.2.0' of module 'Azure' is already installed at 'C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure'. To install version '5.1.1' , run Install-Module and add the -Force parameter. This command will install both version '4.2.0' and version '5.1.1'."
however i would rather have only one version than two that cause some conflict to other commands.
So I next do
Uninstall-Module 'Azure'
which succeeds , which I assume means all versions have been in installed.
then when I again try to fire Install-Module , the same error shows up.
How do I Clean up?
Upvotes: 3
Views: 3894
Reputation: 379
Used this to uninstall old version of AzureRM modules:
Get-Module -ListAvailable Azure* | Group-Object -Property Name | Where {$_.Count -gt 1} | foreach {$_.Group | sort Version -Descending | select -Last 1} | Uninstall-Module -Force
Upvotes: 0
Reputation: 16096
To only add or remove modules by version, try using the -*Version options of the Install-Module cmdlet.
'learn.microsoft.com/en-us/powershell/module/powershellget/install-module?view=powershell-5.1'
[-MinimumVersion ] [-MaximumVersion ]
Upvotes: 0