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?
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.