打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
使用 PowerShellGet 在 Windows 上安装 Azure PowerShell | Microsoft Docs

您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

使用 PowerShellGet 在 Windows 上安装 Azure PowerShell

  • 作者

本文介绍了在 Windows 环境中使用 PowerShellGet 安装 Azure PowerShell 模块的步骤。 PowerShellGet 和模块管理是安装 Azure PowerShell 的首选方法,但是如果希望使用 Web 平台安装程序或 MSI 包进行安装,请参阅其他安装方法

有关如何在其他平台上安装 Azure PowerShell 的说明,请参阅在 macOS 和 Linux 上安装和配置 Azure PowerShell

此版 Azure PowerShell 不支持 Azure 经典部署模型。 若要获取经典部署的支持,请按安装 Azure PowerShell 服务管理模块中的说明操作。

要求

从 Azure PowerShell 版本 6.0 开始,Azure PowerShell 需要 PowerShell 版本 5.0。 若要查看在计算机上运行的 PowerShell 的版本,请运行以下命令:

PowerShell
$PSVersionTable.PSVersion

如果版本已过时,请参阅升级现有的 Windows PowerShell

重要

本文档中介绍的模块 AzureRM 使用 .NET Framework。 这使得它与使用 .NET Core 的 PowerShell 6.0 兼容。 如果使用的是 PowerShell 6.0,请遵循适用于 macOS 和 Linux 的安装说明

安装 Azure Powershell 模块

需要提升的权限才能通过 PowerShell 库安装模块。 若要安装 Azure PowerShell,请在已提升权限的会话中运行以下命令:

PowerShell
Install-Module -Name AzureRM

备注

如果使用的 NuGet 版本低于 2.8.5.201,系统会提示下载并安装最新版本的 NuGet。

默认情况下,PowerShell 库未配置为 PowerShellGet 的受信任存储库。 首次使用 PSGallery 时会看到以下提示:

output
Untrusted repositoryYou are installing the modules from an untrusted repository. If you trust this repository, changeits InstallationPolicy value by running the Set-PSRepository cmdlet.Are you sure you want to install the modules from 'PSGallery'?[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"):

请回答 YesYes to All 继续安装。

AzureRM 模块是 Azure PowerShell cmdlet 的汇总模块。 安装它时,系统会下载所有可用的 Azure 资源管理器模块并使其 cmdlet 可供使用。

登录

若要开始使用 Azure PowerShell,需使用 Import-Module cmdlet 将 AzureRM 加载到当前的 PowerShell 会话中,然后使用 Azure 凭据登录。

PowerShell
# Import the module into the PowerShell sessionImport-Module AzureRM# Connect to Azure with an interactive dialog for sign-inConnect-AzureRmAccount

需对每个启动的新 PowerShell 会话重复这些步骤。 自动导入 AzureRM 模块要求设置 PowerShell 配置文件,详见关于配置文件若要了解如何跨会话保持 Azure 登录状态,请参阅跨 PowerShell 会话保持用户凭据

更新 Azure PowerShell 模块

可以通过运行 Update-Module 来更新 Azure PowerShell 安装。 此命令不卸载以前的版本。

PowerShell
Update-Module -Name AzureRM

若要从系统中删除旧版 Azure PowerShell,请参阅卸载 Azure PowerShell 模块

使用多个版本的 Azure PowerShell

可以安装多个版本的 Azure PowerShell。 如果使用本地 Azure Stack 资源、运行不能更新到 PowerShell 5.0 的旧版 Windows,或者使用 Azure 经典部署模型,则可能需要多个版本。 若要安装旧版本,请在安装时提供 -RequiredVersion 参数。

PowerShell
# Install version 1.2.9 of Azure PowerShellInstall-Module -Name AzureRM -RequiredVersion 1.2.9

加载 Azure PowerShell 模块时,默认加载最新版本。 若要加载另一版本,请提供 -RequiredVersion 参数。

PowerShell
# Load version 1.2.9 of Azure PowerShellImport-Module -Name AzureRM -RequiredVersion 1.2.9

提供反馈

如果在使用 Azure Powershell 时发现 Bug,请在 GitHub 上提出问题若要从命令行提供反馈,请使用 Send-Feedback cmdlet。

后续步骤

若要开始使用 Azure PowerShell,请参阅 Azure PowerShell 入门,详细了解此模块及其功能。

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
爱上PowerShell
如何更换win10默认的powershell1.0为powershell7?
Azure PowerShell 首次接触 - 安装篇
微软 Windows Server 不同版本之间的差异有哪些?
powershell版本的确定
win10一个重磅工具升级,PowerShell7推出,新版本变化太大
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服