PowerShell Genie
Practice Find stopped Azure VMs

Find stopped Azure VMs: practice drill

Exercise 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Return the VMs that are stopped, with their resource groups.

The task

Stopped VMs still hold their disks and their costs. List them with their resource groups so the team can decide what to deallocate.

Target

Return the VMs that are stopped, with their resource groups.

What the result tells you

PowerState describes the VM's current state. Filtering for 'VM stopped' isolates the machines that are off but still allocated.

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.

Why does the source command need -Status?

Choose an answer, then check your reasoning.

Worked solution

Worked solution

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

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 guideFind stopped Azure VMs: practice drill

Return the VMs that are stopped, with their resource groups.