Edit

Share via


Get-AzPolicyExemption

Gets policy exemptions.

Syntax

Name (Default)

Get-AzPolicyExemption
    [-Name <String>]
    [-Scope <String>]
    [-PolicyAssignmentIdFilter <String>]
    [-BackwardCompatible]
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

IncludeDescendent

Get-AzPolicyExemption
    [-Scope <String>]
    [-IncludeDescendent]
    [-BackwardCompatible]
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

Id

Get-AzPolicyExemption
    -Id <String>
    [-PolicyAssignmentIdFilter <String>]
    [-BackwardCompatible]
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

Description

The Get-AzPolicyExemption cmdlet gets a collection of policy exemptions or a specific policy exemption identified by name or ID.

Examples

Example 1 Get all policy exemptions

Get-AzPolicyExemption

This command gets all the policy exemptions in the current subscription. If you need to list all the exemptions related to the given scope, including those from ancestor scopes and those from descendent scopes you need to pass the -IncludeDescendent parameter.

Example 2: Get a specific policy exemption

$ResourceGroup = Get-AzResourceGroup -Name 'ResourceGroup11'
Get-AzPolicyExemption -Name 'PolicyExemption07' -Scope $ResourceGroup.ResourceId

The first command gets a resource group named ResourceGroup11 by using the Get-AzResourceGroup cmdlet and stores it in the $ResourceGroup variable. The second command gets the policy exemption named PolicyExemption07 for the scope that the ResourceId property of $ResourceGroup identifies.

Example 3: Get all policy exemptions associated with a policy assignment

$ResourceGroup = Get-AzResourceGroup -Name 'ResourceGroup11'
$Assignment = Get-AzPolicyAssignment -Name 'PolicyAssignment07' -Scope $ResourceGroup.ResourceId
Get-AzPolicyExemption -PolicyAssignmentIdFilter $Assignment.Id

The first command gets a policy assignment named PolicyAssignment07. The second command gets all of the policy exemptions that are assigned with the policy assignment.

Parameters

-BackwardCompatible

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

Parameter properties

Type:SwitchParameter
Default value:None
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

-DefaultProfile

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

Parameter properties

Type:PSObject
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzureRMContext, AzureCredential

Parameter sets

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

-Id

The fully qualified resource Id of the exemption.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:ResourceId

Parameter sets

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

-IncludeDescendent

Causes the list of returned policy exemptions to include all exemptions related to the given scope, including those from ancestor scopes and those from descendent scopes. If not provided, only exemptions at and above the given scope are included.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

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

-Name

The name of the policy exemption.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:PolicyExemptionName

Parameter sets

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

-PolicyAssignmentIdFilter

The policy assignment id filter.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

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

-Scope

The scope of the policy exemption. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Name
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
IncludeDescendent
Position:Named
Mandatory:False
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

SwitchParameter

String

Outputs

IPolicyExemption