Challenge - 5 Problems
Azure PowerShell Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Azure PowerShell command?
You run the following command to list all resource groups in your Azure subscription:
What will this command output?
Get-AzResourceGroup | Select-Object -First 1 -Property ResourceGroupNameWhat will this command output?
PowerShell
Get-AzResourceGroup | Select-Object -First 1 -Property ResourceGroupNameAttempts:
2 left
💡 Hint
Think about what Select-Object does when you specify a property and limit the output to the first item.
✗ Incorrect
The command gets all resource groups, then selects only the first one and shows its ResourceGroupName property inside an object format.
📝 Syntax
intermediate1: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?
Attempts:
2 left
💡 Hint
The current Azure PowerShell module uses 'Az' prefix commands.
✗ Incorrect
The correct command to log in is Connect-AzAccount. The others are either deprecated or invalid.
🔧 Debug
advanced2:30remaining
Why does this script fail to create a resource group?
You run this script to create a resource group but get an error:
Variables $rgName and $location are set as:
What is the most likely cause of the error?
New-AzResourceGroup -Name $rgName -Location $locationVariables $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
Attempts:
2 left
💡 Hint
Check if you have an active Azure session before creating resources.
✗ Incorrect
If you are not logged in with Connect-AzAccount, the command will fail because it cannot authenticate.
🚀 Application
advanced3: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?
Attempts:
2 left
💡 Hint
You need to get the VM status to filter running VMs before stopping them.
✗ Incorrect
Get-AzVM -Status retrieves VM status including PowerState. Filtering on PowerState 'VM running' ensures only running VMs are stopped.
🧠 Conceptual
expert3:00remaining
What is the effect of running this Azure PowerShell pipeline?
Consider this command:
What does this command do?
Get-AzResource -ResourceType 'Microsoft.Compute/virtualMachines' | Where-Object {$_.Location -eq 'westus'} | Remove-AzResource -ForceWhat does this command do?
PowerShell
Get-AzResource -ResourceType 'Microsoft.Compute/virtualMachines' | Where-Object {$_.Location -eq 'westus'} | Remove-AzResource -Force
Attempts:
2 left
💡 Hint
Look at the pipeline: it filters VMs by location, then deletes them with -Force to skip confirmation.
✗ Incorrect
The command gets all VMs, filters those in 'westus', then deletes them forcefully without confirmation prompts.