How to get the tags of the availability set using PowerShell?



There are two ways to retrieve the availability set tags. Using the Tags property inside the availability tag and the second by using the Get-AzTag command.

Before running this 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).

First, we will get the availability set properties and retrieve the tag property as shown below.

$availablityset = Get-AzAvailabilitySet -ResourceGroupName
MYRESOURCEGROUPAVAILABILITY -Name myAvailabilitySet

$availablityset.Tags

Output

To get the tags using resource ID, we need to retrieve the resource ID using the Get-AvailabilitySet command.

$availablityset = Get-AzAvailabilitySet -ResourceGroupName
MYRESOURCEGROUPAVAILABILITY -Name myAvailabilitySet

Get-AzTag -ResourceId $availablityset.Id | Select -
ExpandProperty Properties

Output


Advertisements