Microsoft Docs

Get Started with Azure PowerShell

Welcome to the Azure PowerShell documentation. This guide will help you install and start using Azure PowerShell to manage your Azure resources.

Prerequisites

Installation

The recommended way to install Azure PowerShell is by using the PowerShell Gallery. You can install the latest version by running the following commands:

Step 1: Install the Az module
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

This command installs the Az module, which contains all the cmdlets for managing Azure resources. The -Scope CurrentUser flag ensures that you don't need administrative privileges to install.

Step 2: Verify the installation
Get-Module -Name Az -ListAvailable

You should see the installed Az module and its version listed.

Important: If you have older AzureRM modules installed, you should uninstall them before installing the Az module. For instructions, see Migrate from AzureRM to the Az module.

Connecting to Azure

Once installed, you need to connect your PowerShell session to your Azure account.

Connect-AzAccount

This command will open a browser window where you can sign in to your Azure account. After successful authentication, your Azure account information will be loaded into your PowerShell session.

Managing Azure Resources

Now you can start managing your Azure resources using Azure PowerShell cmdlets. Here are a few common examples:

Listing all subscriptions

Get-AzSubscription

Listing resource groups in the current subscription

Get-AzResourceGroup

Creating a new resource group

New-AzResourceGroup -Name "MyResourceGroup" -Location "East US"

Discovering Cmdlets

You can find cmdlets related to a specific Azure service using the Get-Command cmdlet.

Get-Command -Module Az.Storage

This will list all cmdlets available in the Az.Storage module.

Further Learning