Azure Documentation

Install Azure PowerShell

This guide will walk you through the process of installing Azure PowerShell on your local machine. Azure PowerShell provides cmdlets that you can use to manage your Azure resources.

Prerequisites

Installation Methods

You can install Azure PowerShell using the PowerShellGet module, which is the recommended method. Alternatively, for certain scenarios, you might use other package managers.

Method 1: Using PowerShellGet (Recommended)

This method installs the Az module, which is the current and recommended module for managing Azure resources with PowerShell.

  1. Open PowerShell as Administrator:

    Search for 'PowerShell' in the Windows Start menu, right-click on 'Windows PowerShell', and select 'Run as administrator'. On macOS or Linux, open your terminal.

  2. Install the Az PowerShell module:

    Run the following command to install the latest version of the Az module:

    Install-Module -Name Az -AllowClobber -Scope CurrentUser

    If you are prompted to install the NuGet provider, type Y and press Enter.

    If you are prompted to install from an untrusted repository, type Y and press Enter.

  3. Verify the installation:

    After the installation is complete, you can verify it by listing the installed Az modules:

    Get-Module -ListAvailable -Name Az
  4. Connect to your Azure account:

    To start managing your Azure resources, connect to your Azure account:

    Connect-AzAccount

    This command will open a browser window for you to sign in to your Azure account.

Method 2: Installing for Specific Cloud Environments (e.g., Azure Government)

If you need to manage resources in specific Azure cloud environments like Azure Government, you'll need to specify the AzEnvironmentName parameter during installation and connection.

Example for Azure Government:
# Install the Az.Accounts module for Azure Government
Install-Module -Name Az.Accounts -Scope CurrentUser -AzEnvironmentName AzureUSGovernment

# Connect to Azure Government
Connect-AzAccount -EnvironmentName AzureUSGovernment

Managing Modules

You can update the Az module to the latest version using:

Update-Module -Name Az

To uninstall the Az module:

Uninstall-Module -Name Az -Force -Verbose

Troubleshooting Common Issues

Execution Policy: If you encounter issues running PowerShell commands, you might need to adjust your execution policy. Run Set-ExecutionPolicy RemoteSigned -Scope CurrentUser (with administrator privileges) to allow scripts from trusted sources.

For more detailed information and advanced scenarios, please refer to the official Azure PowerShell documentation.