Azure PowerShell is a set of cmdlets for managing Azure resources directly from the PowerShell command line. It provides a powerful scripting environment for automating tasks, deploying resources, and managing services.
Install the Az module, connect to your Azure account, and start managing resources.
# Install the Az module (once)
Install-Module -Name Az -Repository PSGallery -Force
# Import the module
Import-Module Az
# Sign in to Azure
Connect-AzAccount
# Verify the subscription
Get-AzSubscriptionBelow are some frequently used cmdlets.
# List all resource groups
Get-AzResourceGroup
# Create a new resource group
New-AzResourceGroup -Name MyResourceGroup -Location eastus
# Deploy an ARM template
New-AzResourceGroupDeployment -ResourceGroupName MyResourceGroup -TemplateFile .\template.json
# List virtual machines
Get-AzVM
# Start a VM
Start-AzVM -Name MyVM -ResourceGroupName MyResourceGroup
# Stop a VM
Stop-AzVM -Name MyVM -ResourceGroupName MyResourceGroup -Force