0
0
PowerShellscripting~20 mins

Azure PowerShell module - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Azure PowerShell Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Azure PowerShell command?
You run the following command to list all resource groups in your Azure subscription:

Get-AzResourceGroup | Select-Object -First 1 -Property ResourceGroupName

What will this command output?
PowerShell
Get-AzResourceGroup | Select-Object -First 1 -Property ResourceGroupName
AAn error saying 'Get-AzResourceGroup' is not recognized
BA list of all resource group names in plain text
CAn object showing the name of the first resource group, e.g., @{ResourceGroupName=MyResourceGroup}
DAn empty output with no resource groups listed
Attempts:
2 left
💡 Hint
Think about what Select-Object does when you specify a property and limit the output to the first item.
📝 Syntax
intermediate
1:30remaining
Which option correctly logs in to Azure using PowerShell?
You want to log in to your Azure account using PowerShell. Which command syntax is correct?
AConnect-AzAccount
BLogin-AzAccount
CConnect-AzureRmAccount
DLogin-AzureAccount
Attempts:
2 left
💡 Hint
The current Azure PowerShell module uses 'Az' prefix commands.
🔧 Debug
advanced
2:30remaining
Why does this script fail to create a resource group?
You run this script to create a resource group but get an error:

New-AzResourceGroup -Name $rgName -Location $location

Variables $rgName and $location are set as:
$rgName = 'TestGroup'
$location = 'eastus'


What is the most likely cause of the error?
PowerShell
$rgName = 'TestGroup'
$location = 'eastus'
New-AzResourceGroup -Name $rgName -Location $location
AThe New-AzResourceGroup cmdlet does not accept the -Location parameter
BThe location 'eastus' is invalid and misspelled
CThe variable $rgName is empty
DYou are not logged in to Azure before running the command
Attempts:
2 left
💡 Hint
Check if you have an active Azure session before creating resources.
🚀 Application
advanced
3:00remaining
How to automate stopping all running Azure VMs in a subscription?
You want to write a PowerShell script that stops all running virtual machines in your Azure subscription. Which script snippet correctly does this?
AGet-AzVM -Status | Where-Object {$_.PowerState -eq 'VM running'} | Stop-AzVM -Force
BGet-AzVM | Where-Object {$_.PowerState -eq 'VM running'} | Stop-AzVM -Force
CGet-AzVM | Stop-AzVM -Force
DGet-AzVM -Status | Stop-AzVM -Force
Attempts:
2 left
💡 Hint
You need to get the VM status to filter running VMs before stopping them.
🧠 Conceptual
expert
3:00remaining
What is the effect of running this Azure PowerShell pipeline?
Consider this command:

Get-AzResource -ResourceType 'Microsoft.Compute/virtualMachines' | Where-Object {$_.Location -eq 'westus'} | Remove-AzResource -Force

What does this command do?
PowerShell
Get-AzResource -ResourceType 'Microsoft.Compute/virtualMachines' | Where-Object {$_.Location -eq 'westus'} | Remove-AzResource -Force
ALists all virtual machines in West US but does not delete them
BDeletes all virtual machines located in the West US region without asking for confirmation
CDeletes all resources in the subscription regardless of type or location
DThrows an error because Remove-AzResource cannot be piped input
Attempts:
2 left
💡 Hint
Look at the pipeline: it filters VMs by location, then deletes them with -Force to skip confirmation.