Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Set-AzureResourceGroup

Set-AzureResourceGroup

microsoft.azure.commands.resources.dll

Synopsis

Changes the properties of a resource group

Syntax

Set-AzureResourceGroup [-Name] [-Tag] [<CommonParameters>]

Detailed Description

The Set-AzureResourceGroup cmdlet changes the properties of a resource group. You can use this cmdlet to add, change, or delete the Azure tags applied to a resource group. Use the Name parameter to identify the resource group and the Tag parameter to change the tags. You cannot use this cmdlet to change the name of a resource group.

Parameters

-Name <String>

Specifies the name of the resource group. This parameter identifies the resource group that you want to change.

Aliases

None

Required?

true

Position

0

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Tag <Hashtable[]>

Replaces the tags for the resource group with the specified tags. To add or change a single tag, you must replace the collection of tags for the resource group.A "tag" is a name-value pair that you can create and apply to resources and resource groups. After you assign tags to resources and groups, you can use the Tag parameters of Get-AzureResource and Get-AzureResourceGroup to search for resources and groups by tag name or name and value. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources.Each tag must have a Name key. It can also have an optional Value key with one value. To specify a tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}.To delete a tag, enter a hash table with all tags currently applied to the resource group (from Get-AzureResourceGroup), except for the tag you want to delete. To delete all tags from a resource group, enter an empty hash table (-Tag @{}).

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

Input Type

None

Return Type

Microsoft.Azure.Commands.Resources.Models.PSResourceGroup

Notes

Examples

-------------------------- Example 1: Apply a tag to a resource group --------------------------

This command applies a "Department" tag with a value of "IT" to a resource group that has no existing tags.

PS C:\>Set-AzureResourceGroup -Name ContosoRG -Tag @{Name="Department";Value="IT"}

-------------------------- Example 2: Add tags to a resource group --------------------------

This command adds a "Status" tag with a value of "Approved" and an "FY2016" tag to a resource group that has existing tags. Because the tags you specify replace the existing tags, you must include the existing tags in the new tag collection or you will lose them.

PS C:\>$tags = (Get-AzureResourceGroup -Name ContosoRG).Tags

PS C:\>$tags


Tags: 

      Name        Value
      ====        ======
      Department  IT


PS C:\>$tags += @{Name="Status";Value="Approved"}, @{Name="FY2016"}

PS C:\>Set-AzureResourceGroup -Name ContosoRG -Tag $tags

PS C:>(Get-AzureResourceGroup -Name ContosoRG).Tags


Tags: 

      Name        Value
      ====        ======
      Department  IT
      Status      Approved
      FY2016

-------------------------- Example 3: Delete all tags --------------------------

This command deletes all tags from the ContosoRG resource group. It uses the Tag parameter with an empty hash table value.

PS C:\>Set-AzureResourceGroup -Name ContosoRG -Tag @{}

Online Version