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

使用 MSI 在 Windows 上安装 Azure PowerShellInstall Azure PowerShell on Windows with MSI

本文介绍如何使用 MSI 安装程序在 Windows 上安装 Azure PowerShell。This article explains how to install Azure PowerShell on Windows using an MSI installer. MSI 安装程序是为 PowerShell 库可能被防火墙阻止或需要脱机安装程序的环境提供的。The MSI installer is provided for environments where the PowerShell Gallery may be blocked by a firewall, or an offline installer is needed. 若要安装 Azure PowerShell,建议的方法是使用 PowerShellGet。The recommended way to install Azure PowerShell is with PowerShellGet. 有关使用 PowerShellGet 安装 Azure PowerShell 的说明,请参阅使用 PowerShellGet 安装 Azure PowerShellFor instructions on using PowerShellGet to install Azure PowerShell, see Install Azure PowerShell with PowerShellGet.

要求Requirements

Azure PowerShell 的 MSI 安装程序仅适用于 Windows 上的 PowerShell 5.1 。The MSI installer for Azure PowerShell works only for PowerShell 5.1 on Windows. 若要在非 Windows 平台或更高版本的 powershell 上安装,请通过 PowerShellGet 安装For installation on non-Windows platforms or later versions of powershell, Install with PowerShellGet. 若要检查 PowerShell 版本,请运行以下命令:To check your PowerShell version, run the command:

$PSVersionTable.PSVersion

若要在 PowerShell 5.1 中使用 Azure PowerShell,需要:To use Azure PowerShell in PowerShell 5.1, you need to:

  1. 在必要时更新到 Windows PowerShell 5.1Update to Windows PowerShell 5.1 if needed. 如果是在 Windows 10 平台上,则已安装 PowerShell 5.1。If you're on Windows 10, you already have PowerShell 5.1 installed.
  2. 安装 .NET Framework 4.7.2 或更高版本Install .NET Framework 4.7.2 or later.

使用 MSI 包在 Windows 上进行安装或更新Install or update on Windows using the MSI Package

使用 GitHub 中提供的 MSI 文件安装适用于 Windows 的 Azure PowerShell。Azure PowerShell for Windows is installed using the MSI file available from GitHub. 如果已将早期版本 Azure 模块作为 MSI 安装,安装程序会自动删除这些模块。If you have installed earlier versions of Azure modules as an MSI, the installer automatically removes them. MSI 包在 ${env:ProgramFiles}\WindowsPowerShell\Modules 中安装模块。The MSI package installs modules in ${env:ProgramFiles}\WindowsPowerShell\Modules.

若要开始使用 Azure PowerShell,请通过 Azure 凭据登录。To start working with Azure PowerShell, sign in with your Azure credentials.

# Connect to Azure with an interactive dialog for sign-in
Connect-AzAccount

备注

如果已禁用模块自动加载,则需使用 Import-Module Az 手动导入模块。If you've disabled module autoloading, you need to manually import the module with Import-Module Az. 由于模块的构造方式,这可能需要一分钟时间。Because of the way the module is structured, this can take up to a minute.

需要在每个新启动的 PowerShell 会话中重复此步骤。You'll need to repeat this step for every new PowerShell session you start. 若要了解如何跨 PowerShell 会话保持 Azure 登录状态,请参阅跨 PowerShell 会话保持用户凭据To learn how to persist your Azure sign-in across PowerShell sessions, see Persist user credentials across PowerShell sessions.

提供反馈Provide feedback

如果发现 Azure Powershell 中存在 bug,请在 GitHub 上提出问题If you find a bug in Azure Powershell, file an issue on GitHub. 若要从命令行提供反馈,请使用 Send-Feedback cmdlet。To provide feedback from the command line, use the Send-Feedback cmdlet.

后续步骤Next Steps

若要详细了解 Azure PowerShell 模块及其功能,请参阅 Azure PowerShell 入门To learn more about the Azure PowerShell modules and their features, see Get Started with Azure PowerShell. 如果你熟悉 Azure PowerShell 并且需要从 AzureRM 进行迁移,请参阅从 AzureRM 迁移到 AzIf you're familiar with Azure PowerShell and need to migrate from AzureRM, see Migrate from AzureRM to Az.