Redigera

Dela via


Update-AzPolicyDefinition

This operation updates an existing policy definition in the given subscription or management group with the given name.

Syntax

Update-AzPolicyDefinition
      -Name <String>
      [-DisplayName <String>]
      [-Description <String>]
      [-Policy <String>]
      [-Metadata <String>]
      [-Parameter <String>]
      [-Mode <String>]
      [-BackwardCompatible]
      [-DefaultProfile <PSObject>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Update-AzPolicyDefinition
      -Name <String>
      -SubscriptionId <String>
      [-DisplayName <String>]
      [-Description <String>]
      [-Policy <String>]
      [-Metadata <String>]
      [-Parameter <String>]
      [-Mode <String>]
      [-BackwardCompatible]
      [-DefaultProfile <PSObject>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Update-AzPolicyDefinition
      -Name <String>
      -ManagementGroupName <String>
      [-DisplayName <String>]
      [-Description <String>]
      [-Policy <String>]
      [-Metadata <String>]
      [-Parameter <String>]
      [-Mode <String>]
      [-BackwardCompatible]
      [-DefaultProfile <PSObject>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Update-AzPolicyDefinition
      -Id <String>
      [-DisplayName <String>]
      [-Description <String>]
      [-Policy <String>]
      [-Metadata <String>]
      [-Parameter <String>]
      [-Mode <String>]
      [-BackwardCompatible]
      [-DefaultProfile <PSObject>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Update-AzPolicyDefinition
      [-DisplayName <String>]
      [-Description <String>]
      [-Policy <String>]
      [-Metadata <String>]
      [-Parameter <String>]
      [-Mode <String>]
      [-BackwardCompatible]
      -InputObject <IPolicyDefinition>
      [-DefaultProfile <PSObject>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

This operation updates an existing policy definition in the given subscription or management group with the given name.

Examples

Example 1: Update the description of a policy definition

$PolicyDefinition = Get-AzPolicyDefinition -Name 'VMPolicyDefinition'
Update-AzPolicyDefinition -Id $PolicyDefinition.ResourceId -Description 'Updated policy to not allow virtual machine creation'

The first command gets a policy definition named VMPolicyDefinition by using the Get-AzPolicyDefinition cmdlet. The command stores that object in the $PolicyDefinition variable. The second command updates the description of the policy definition identified by the ResourceId property of $PolicyDefinition.

Example 2: Update the mode of a policy definition

Update-AzPolicyDefinition -Name 'VMPolicyDefinition' -Mode 'All'

This command updates the policy definition named VMPolicyDefinition by using the Update-AzPolicyDefinition cmdlet to set its mode property to 'All'.

Example 3: Update the metadata of a policy definition

Update-AzPolicyDefinition -Name 'VMPolicyDefinition' -Metadata '{"category":"Virtual Machine"}'

This command updates the metadata of a policy definition named VMPolicyDefinition to indicate its category is "Virtual Machine".

Example 3: [Backcompat] Update the mode of a policy definition

Set-AzPolicyDefinition -Name 'VMPolicyDefinition' -Mode 'All'

This command updates the policy definition named VMPolicyDefinition by using the Set-AzPolicyDefinition alias of the Update-AzPolicyDefinition cmdlet to set its mode property to 'All'.

Parameters

-BackwardCompatible

Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.

Type:PSObject
Aliases:AzureRMContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Description

The policy definition description.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-DisplayName

The display name of the policy definition.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Id

The resource Id of the policy definition to update.

Type:String
Aliases:ResourceId
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-InputObject

Type:IPolicyDefinition
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ManagementGroupName

The ID of the management group.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Metadata

The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Mode

The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Name

The name of the policy definition to update.

Type:String
Aliases:PolicyDefinitionName
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Parameter

The parameter definitions for parameters used in the policy rule. The keys are the parameter names.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Policy

The policy rule.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-SubscriptionId

The ID of the target subscription.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

IPolicyDefinition

String

Outputs

IPolicyDefinition

Notes

ALIASES

Set-AzPolicyDefinition