Edit

Set-AzResourceGroup

Replaces the tags on a resource group.

Syntax

SetByResourceGroupName (Default)

Set-AzResourceGroup
    [-Tag] <hashtable>
    -Name <string>
    [-SubscriptionId <string>]
    [-Profile <string>]
    [<CommonParameters>]

SetByResourceGroupId

Set-AzResourceGroup
    [-Tag] <hashtable>
    -Id <string>
    [-SubscriptionId <string>]
    [-Profile <string>]
    [<CommonParameters>]

Aliases

This cmdlet has no aliases.

Description

The Set-AzResourceGroup cmdlet replaces all tags on an existing resource group. Specify the resource group by name or by its full ARM resource ID. Because the supplied tag collection replaces the existing collection, include any tags that you want to retain. Use an empty hashtable to remove all tags.

Examples

Example 1: Replace resource group tags by name

Replace all tags on a resource group in the active subscription.

Set-AzResourceGroup -Name myResourceGroup -Tag @{ Environment = 'Production'; Owner = 'Platform' }

Example 2: Replace resource group tags by resource ID

Identify the resource group with its full ARM resource ID.

Set-AzResourceGroup -Id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup -Tag @{ CostCenter = '1234' }

Example 3: Remove all resource group tags

Pass an empty hashtable to clear the existing tags.

Set-AzResourceGroup -Name myResourceGroup -Tag @{}

Parameters

-Id

Specifies the full ARM resource ID of the resource group.

Parameter properties

Type:String
Supports wildcards:False
DontShow:False
Aliases:ResourceGroupId, ResourceId

Parameter sets

SetByResourceGroupId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

Specifies the name of the resource group.

Parameter properties

Type:String
Supports wildcards:False
DontShow:False
Aliases:ResourceGroupName

Parameter sets

SetByResourceGroupName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Profile

Specifies a saved profile to use instead of the active profile.

Parameter properties

Type:String
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SubscriptionId

Specifies the Azure subscription ID. When omitted, the cmdlet uses the active profile's subscription. The subscription encoded in Id takes precedence when the ID parameter set is used.

Parameter properties

Type:String
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Tag

Specifies the complete hashtable of tags to apply to the resource group. The supplied tags replace all existing tags. Null values are sent as empty strings.

Parameter properties

Type:Hashtable
Supports wildcards:False
DontShow:False
Aliases:Tags

Parameter sets

(All)
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

You can pipe a resource group name to this cmdlet by property name.

Hashtable

You can pipe a tag hashtable to this cmdlet by property name.

Outputs

Microsoft.Azure.Azclips.Extensions.Resources.Models.ResourceGroup

Returns the updated resource group.

Notes

This cmdlet replaces tags; it does not merge them with the existing tag collection.