November 21st, 2014

PowerTip: Identify All Stopped Azure Virtual Machines with PowerShell

Doctor Scripto
Scripter

Summary: Identify virtual machines that are shut down, but are consuming billing time.

Hey, Scripting Guy! Question How can I use Windows PowerShell to track virtual machines that are not shut down from
           the management portal in Azure?

Hey, Scripting Guy! Answer Use the Get-AzureVM cmdlet, and filter on 'StoppedVM' status:

Get-AzureVM | Where { $_.Status –eq 'StoppedVM' }

You can then properly shut down all of them with the Stop-AzureVM cmdlet:

Get-AzureVM | Where { $_.Status –eq 'StoppedVM' } | Stop-AzureVM

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback