Mandar Jogalekar
Mandar Jogalekar

Reputation: 3281

Install Module and remove all previous powershell

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

Answers (3)

Vijred
Vijred

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

postanote
postanote

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

Jason Ye
Jason Ye

Reputation: 13954

As a workaround, maybe we can download Azure powershell 5.1.1 msi to install it on your windows.

We can download PowerShell 5.1.1 MSI from this link.

Use this to install Azure PowerShell 5.1.1 will remove old version.

Hope this helps.

Upvotes: 1

Related Questions