PowerShell Genie
Practice Find deallocated Azure VMs

Find deallocated Azure VMs

Exercise 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Return the VMs that are deallocated.

An example to inspect

Preview the example. Sign in for the full lesson and activities.

Get-AzVM -Status | Where-Object PowerState -eq 'VM deallocated' | Select-Object Name

The task

Deallocated VMs release their compute costs. Confirm which VMs are in that state before the cost report goes out.

Target

Return the VMs that are deallocated.

What the result tells you

'VM deallocated' is a distinct state from 'VM stopped': deallocated releases the hardware allocation, stopped keeps it reserved.

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 is the difference between stopped and deallocated?

Choose an answer, then check your reasoning.

Worked solution

Worked solution

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

Related reference

Read the command and platform requirements
Back to Practice

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 deallocated Azure VMs

Return the VMs that are deallocated.