PowerShell Genie

Az.Compute module: setup and commands

Module 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Inspect Azure VMs with Get-AzVM, read power state explicitly and manage disks or scale sets without confusing configuration with live status.

Getting it

Install-PSResource -Name Az.Compute from the PowerShell Gallery, or install the Az bundle to get it with everything else.

Examples

1PS> Get-AzVM -Status
Show reference output
1 ResourceGroupName Name Location PowerState
2 ----------------- ----- ------------ --------------
3 RG-PROD WEB01 eastus VM running
4 RG-PROD APP01 eastus VM running
5 RG-DEV DEV01 centralindia VM deallocated
1PS> Get-AzVM -ResourceGroupName rg-app -Name web01
Show reference output
1 ResourceGroupName Name Location PowerState
2 ----------------- ----- ------------ --------------
3 RG-PROD WEB01 eastus VM running
4 RG-PROD APP01 eastus VM running
5 RG-DEV DEV01 centralindia VM deallocated

What it is for

Use it for VM inventory, power state reporting, and scripted start or deallocate schedules. It is also how you read the extensions installed on a VM when you are chasing a misbehaving agent.

Typical tasks

  • List VMs with size and location
  • Find deallocated or stopped VMs
  • Report unattached managed disks
  • Check which extensions a VM has installed
  • Start or deallocate a VM on a schedule
  • Audit the OS image a VM was built from

Check the installed version

1PS> Get-Module -ListAvailable Az.Compute | Select-Object Name, Version, Path
2PS> Get-Command -Module Az.Compute

Compare the module path and version with the session used by your scheduled task or automation account. Use it for VM inventory, power state reporting, and scripted start or deallocate schedules. It is also how you read the extensions installed on a VM when you are chasing a misbehaving agent.

Primary documentation

PowerShell objects and pipelines documentation

Continue
Genie guideAz.Compute module: setup and commands

Inspect Azure VMs with Get-AzVM, read power state explicitly and manage disks or scale sets without confusing configuration with live status.