Reputation: 11625
I have Azure PowerShell 1.0.3 installed via the Gallery (per the instructions here in the Installing Azure PowerShell From The Gallery section). I want to update to the latest version but am unclear on the commands that I need to run. I tried the following, but decided to ask rather than potentially corrupt my installation:
PS C:\Windows\system32> Install-Module AzureRM
You are installing the module(s) from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet.
Are you sure you want to install software from 'https://www.powershellgallery.com/api/v2/'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
WARNING: Version '1.0.3' of module 'AzureRM' is already installed at 'C:\Program
Files\WindowsPowerShell\Modules\AzureRM\1.0.3'. To delete version '1.0.3' and install version '1.1.0', run
Install-Module, and add the -Force parameter.
Can someone provide a script to update Azure PowerShell?
Upvotes: 14
Views: 22058
Reputation: 7
I use :
$azureRMs = Get-Module
foreach($azureRM in $azureRMs)
{
if($azureRM.name -like "AzureRM*" )
{
write-host "removing" $azureRM
remove-Module -Name $azureRM
Uninstall-Module -Name $azureRM
}
}
Install-Module azureRM
Upvotes: 0
Reputation: 2499
The command you need to run is in the help text you posted. Use Install-Module -Force AzureRM
. See the -Force
tag.
Once you've updated the bootstrapper, run Install-AzureRM
to install the new packages.
PowerShell has an Update-Module AzureRM
function that will perform similar activity as Install-Module -Force AzureRM
. You may also want to use the -AllowClobber
argument on Install-Module
if you have functions already defined in your local environment that the AzureRM would overwrite.
However, neither will update your current environment, so prior to running Install-AzureRM
, check to see that you've loaded the latest AzureRM module. For example, if you wanted to update from 1.0.1 to 1.0.3:
$ Get-Module AzureRM
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.1 AzureRM {...}
$ Update-Module AzureRM
$ # This will still be old because we haven't imported the newer version.
$ (Get-Module AzureRM).Version.ToString()
1.0.1
$ Remove-Module AzureRM
$ Import-Module AzureRM
$ (Get-Module AzureRM).Version.ToString()
1.0.3
$ Install-AzureRM
Or you can just open a new PowerShell window after running the update.
Upvotes: 17
Reputation: 463
Best and easy way is from the official link and look for the highlighted. The link will give you MSI of the latest version of AzurePowershell
Upvotes: 0
Reputation: 1960
The most reliable way appears to be:
Download the latest MSI and run it. https://github.com/Azure/azure-powershell/releases
I know you asked for a scripted version... I did not find the various script answers satisfactory. (I didn't want a side-by-side install; Install-AzureRM
wasn't found; etc).
Upvotes: 1
Reputation: 8156
It appears the command has changed a bit, I had to use Install-Module -Force AzureRM -AllowClobber
to get it to update
Upvotes: 11