PowerShell Genie
Practice Review non-running Azure VMs

Review non-running Azure VMs

Exercise 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Return the names and power states of non-running VMs.

The task

Before a maintenance review, identify VMs that are not running and preserve the distinction between stopped and deallocated.

Target

Return the names and power states of non-running VMs.

What the result tells you

Stopped and deallocated are different allocation states. Do not combine them into a single label when the distinction matters to a later action.

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 keep the original power-state value?

Choose an answer, then check your reasoning.

Worked solution

Worked solution

Reveal one approach
1PS> Get-AzVM -Status | Where-Object PowerState -ne 'VM running' | 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 guideReview non-running Azure VMs

Return the names and power states of non-running VMs.