Bearbeiten

Freigeben über


Remove-AzPolicyDefinition

This operation deletes the policy definition in the given subscription with the given name.

Syntax

Remove-AzPolicyDefinition
      -Name <String>
      [-Force]
      [-BackwardCompatible]
      [-DefaultProfile <PSObject>]
      [-PassThru]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzPolicyDefinition
      -Name <String>
      -ManagementGroupName <String>
      [-Force]
      [-BackwardCompatible]
      [-DefaultProfile <PSObject>]
      [-PassThru]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzPolicyDefinition
      -Name <String>
      -SubscriptionId <String>
      [-Force]
      [-BackwardCompatible]
      [-DefaultProfile <PSObject>]
      [-PassThru]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzPolicyDefinition
      -Id <String>
      [-Force]
      [-BackwardCompatible]
      [-DefaultProfile <PSObject>]
      [-PassThru]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzPolicyDefinition
      -InputObject <IPolicyIdentity>
      [-Force]
      [-BackwardCompatible]
      [-DefaultProfile <PSObject>]
      [-PassThru]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

This operation deletes the policy definition in the given subscription with the given name.

Examples

Example 1: Remove the policy definition by name

Remove-AzPolicyDefinition -Name 'VMPolicyDefinition'

This command removes the specified policy definition.

Example 2: Remove policy definition by resource ID

$PolicyDefinition = Get-AzPolicyDefinition -Name 'VMPolicyDefinition' 
Remove-AzPolicyDefinition -Id $PolicyDefinition.ResourceId -Force

This command removes the given policy definition without prompting the user.

Example 3: [Backcompat] Remove policy definition by resource ID

$PolicyDefinition = Get-AzPolicyDefinition -Name 'VMPolicyDefinition' 
Remove-AzPolicyDefinition -Id $PolicyDefinition.ResourceId -Force -BackwardCompatible
True

This command removes the given policy definition without prompting the user.

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

-Force

When $true, skip confirmation prompts

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

-Id

The full Id of the policy definition to get.

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

-InputObject

Identity Parameter To construct, see NOTES section for INPUTOBJECT properties and create a hash table.

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

-ManagementGroupName

The name of the management group.

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

-Name

The name of the policy definition to get.

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

-PassThru

Returns true when the command succeeds

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
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

IPolicyIdentity

String

Outputs

Boolean