如何更新Azure PowerShell?

Gre*_*way 12 azure azure-powershell

我有天青PowerShell的1.0.3通过画廊装(每说明这里在安装Azure中的PowerShell从图库一节).我想更新到最新版本,但我不清楚我需要运行的命令.我尝试了以下内容,但决定询问而不是可能破坏我的安装:

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.
Run Code Online (Sandbox Code Playgroud)

有人可以提供脚本来更新Azure PowerShell吗?

Jer*_*une 14

您需要运行的命令位于您发布的帮助文本中.使用Install-Module -Force AzureRM.-Force标签.

更新引导程序后,运行Install-AzureRM以安装新程序包.

编辑更新(WMF> 4)PowerShell:

PowerShell具有Update-Module AzureRM执行类似活动的功能Install-Module -Force AzureRM.如果您已在本地环境中定义了AzureRM将覆盖的函数,您可能还希望使用该-AllowClobber参数Install-Module.

但是,两者都不会更新您当前的环境,因此在运行之前Install-AzureRM,请检查您是否已加载最新的AzureRM模块.例如,如果要从1.0.1更新到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
Run Code Online (Sandbox Code Playgroud)

或者,您可以在运行更新后打开新的PowerShell窗口.


Pau*_*her 6

看来命令已经改变了一点,我不得不用Install-Module -Force AzureRM -AllowClobber它来更新它