PowerShell Genie

Get-AzVM

Use Get-AzVM to retrieve Azure VM configuration and check power state with Status. See Az module requirements and examples.

Command 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Get-AzVM

Common usage

Get-AzVM -ErrorAction Stop

This is a usage example, not the complete parameter-set reference. Follow Microsoft Learn below for supported parameters and version details.

See the command anatomy

Inspect this authored example with fictional data in the bounded browser model. The numbered stages show how its objects change.

Get-AzVM -ErrorAction Stop
  1. Stage 1Get-AzVM-ErrorAction

    Try it

    Windows PowerShell

    Browser simulation · fictional data; no changes to your computer.

    Interactive simulation · fictional data

    Examples

    Get-AzVM -ErrorAction Stop

    1Get-AzVM -ErrorAction Stop
    Show reference output

    Browser dataset output · the real environment will differ

    Name   ResourceGroupName  PowerState
    -----  -----------------  ----------
    web01  Web                VM running

    Practical use and troubleshooting

    Practical scenario: Use Get-AzVM when you need to retrieve Azure VM configuration and check power state with Status. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: Power state missing from a model-view query requires an instance-view query using -Status. Inspect returned properties; a single named VM exposes status details differently from a subscription-wide list. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Get-AzDisk. Get-AzVM describes virtual machines; Get-AzDisk describes managed disks. A VM's provisioning state is not its power state, and an unattached disk is not a stopped virtual machine. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Get-AzVM reference on Microsoft Learn

    Put this command to work

    Read Azure VM status

    An Azure read context is preloaded in this fictional lab. Return the fictional Azure VM status inventory.

    Review the lesson

    Recap

    Get-AzVM Use Get-AzVM to retrieve Azure VM configuration and check power state with Status. See Az module requirements and examples.

    Next: Get-AzDisk
    Genie guideGet-AzVM

    Use Get-AzVM to retrieve Azure VM configuration and check power state with Status. The console below is pre-loaded — run it, then change a value and run it again.