0
0
PowerShellscripting~30 mins

Azure PowerShell module - Mini Project: Build & Apply

Choose your learning style9 modes available
Azure PowerShell Module Basics
📖 Scenario: You are managing resources in Microsoft Azure. To automate tasks, you will use the Azure PowerShell module. This project will guide you through connecting to Azure, selecting a subscription, and listing resource groups.
🎯 Goal: Build a simple PowerShell script that connects to Azure, sets the subscription, and lists all resource groups.
📋 What You'll Learn
Use the Connect-AzAccount cmdlet to log in to Azure.
Create a variable $subscriptionId with a specific subscription ID.
Use Set-AzContext with $subscriptionId to select the subscription.
Use Get-AzResourceGroup to get all resource groups.
Print the names of all resource groups.
💡 Why This Matters
🌍 Real World
Automating Azure tasks saves time and reduces errors when managing cloud resources.
💼 Career
Azure PowerShell skills are valuable for cloud administrators, DevOps engineers, and IT professionals working with Microsoft Azure.
Progress0 / 4 steps
1
Connect to Azure
Write the command Connect-AzAccount to log in to your Azure account.
PowerShell
Need a hint?

This command opens a login window to enter your Azure credentials.

2
Set Subscription ID Variable
Create a variable called $subscriptionId and set it to the string "12345678-1234-1234-1234-123456789abc".
PowerShell
Need a hint?

Use double quotes around the subscription ID string.

3
Set Azure Context to Subscription
Use the command Set-AzContext -SubscriptionId $subscriptionId to select the subscription.
PowerShell
Need a hint?

This command tells Azure PowerShell which subscription to use for commands.

4
List and Print Resource Groups
Use Get-AzResourceGroup to get all resource groups and store them in $resourceGroups. Then use a foreach loop with variable $rg to print each resource group's name using Write-Output $rg.ResourceGroupName.
PowerShell
Need a hint?

The output will list the names of your resource groups, one per line.