PowerShell Genie
Practice List Lab resource group VMs

List Lab resource group VMs

Exercise 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Return every VM in the Lab resource group.

The task

The Lab resource group is scheduled for cleanup. List its VMs before anything is removed.

Target

Return every VM in the Lab resource group.

What the result tells you

ResourceGroupName scopes the query to one resource group, and keeping PowerState shows at a glance which VMs are actually running.

Verify the result

Run the source by itself and inspect the sample objects. Add each filter separately, then check the final properties and order.

The browser uses a small fictional dataset. Real results depend on the host, module, account and target environment.

What does this pipeline return?

Choose an answer, then check your reasoning.

Worked solution

Worked solution

Reveal one approach
1PS> Get-AzVM -Status | Where-Object ResourceGroupName -eq 'Lab' | Select-Object Name, PowerState

Related reference

Read the command and platform requirements
Next exercise

Try it in the lab

Write your pipeline below and run it against the fictional sample data, then check your result against the expected answer.

Interactive simulation · fictional data
Genie guideList Lab resource group VMs

Return every VM in the Lab resource group.