- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to list the Azure VMs from the Availability set using PowerShell?
To list the Azure VMs under the availability set, we can use the command as shown below
Before running the command make sure that you are connected to the Azure Cloud (if not use ConnectAzAccount) and proper azure subscription (Set-AzContext to set the Azure subscription)
$availabilitySetVMs = Get-AzAvailabilitySet -ResourceGroupName MYRESOURCEGROUPAVAILABILITY -Name myAvailabilitySet
To get the total number of Virtual machines in the availability set,
PS C:\> $availabilitySetVMs.VirtualMachinesReferences.id.count
Output
To get all the VM names from the list, we can use the below command.
$VMlist = Get-AzAvailabilitySet -ResourceGroupName MYRESOURCEGROUPAVAILABILITY -Name myAvailabilitySet $i=0 foreach($vm in $VMlist.VirtualMachinesReferences){ "VM{0}: {1}" -f $i,($vm.Id.Split('/'))[-1] $i++ }
Output
- Related Articles
- How to list the Azure VMs using Azure CLI in PowerShell?
- How to Export the Azure VMs using PowerShell?
- How to retrieve Azure VMs using PowerShell?
- How to find the disk type of the Azure Availability set using PowerShell?
- How to get the fault domain count of the Azure Availability set using PowerShell?
- How to get the update domain count of the Azure Availability set using PowerShell?
- How to get the available Azure VM sizes for the availability set using PowerShell?
- How to get the tags of the availability set using PowerShell?
- How to list the azure VM extensions using Azure CLI in PowerShell?
- How to get the azure resources from the resource group using PowerShell?
- How to deallocate the Azure VM using Azure CLI in PowerShell?
- How to start the Azure VM using Azure CLI in PowerShell?
- How to stop the Azure VM using Azure CLI in PowerShell?
- How to restart the Azure VM using Azure CLI in PowerShell?
- How to resize the Azure VM using Azure CLI in PowerShell?

Advertisements