Update-AzPolicyExemption
This operation updates a policy exemption with the given scope and name.
Update-AzPolicyExemption
-Name <String>
[-Scope <String>]
[-ExemptionCategory <String>]
[-PolicyDefinitionReferenceId <String[]>]
[-DisplayName <String>]
[-Description <String>]
[-ExpiresOn <DateTime>]
[-ClearExpiration]
[-Metadata <String>]
[-ResourceSelector <IResourceSelector[]>]
[-AssignmentScopeValidation <String>]
[-BackwardCompatible]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Update-AzPolicyExemption
[-ExemptionCategory <String>]
[-PolicyDefinitionReferenceId <String[]>]
-Id <String>
[-DisplayName <String>]
[-Description <String>]
[-ExpiresOn <DateTime>]
[-ClearExpiration]
[-Metadata <String>]
[-ResourceSelector <IResourceSelector[]>]
[-AssignmentScopeValidation <String>]
[-BackwardCompatible]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Update-AzPolicyExemption
[-ExemptionCategory <String>]
[-PolicyDefinitionReferenceId <String[]>]
[-DisplayName <String>]
[-Description <String>]
[-ExpiresOn <DateTime>]
[-ClearExpiration]
[-Metadata <String>]
[-ResourceSelector <IResourceSelector[]>]
[-AssignmentScopeValidation <String>]
[-BackwardCompatible]
-InputObject <IPolicyExemption>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
This operation updates a policy exemption with the given scope and name.
$ResourceGroup = Get-AzResourceGroup -Name 'ResourceGroup11'
$PolicyExemption = Get-AzPolicyExemption -Name 'PolicyExemption07' -Scope $ResourceGroup.ResourceId
Update-AzPolicyExemption -Id $PolicyExemption.Id -DisplayName 'Exempt VM creation limit'
The first command gets a resource group named ResourceGroup11 by using the Get-AzResourceGroup cmdlet. The command stores that object in the $ResourceGroup variable. The second command gets the policy exemption named PolicyExemption07 by using the Get-AzPolicyExemption cmdlet. The command stores that object in the $PolicyExemption variable. The final command updates the display name on the policy exemption on the resource group identified by the ResourceId property of $ResourceGroup.
$NextMonth = (Get-Date).AddMonths(1)
$PolicyExemption = Get-AzPolicyExemption -Name 'PolicyExemption07'
Update-AzPolicyExemption -Id $PolicyExemption.Id -ExpiresOn $NextMonth
The first command gets the current date time by using the Get-Date cmdlet and add 1 month to the current date time The command stores that object in the $NextMonth variable. The second command gets the policy exemption named PolicyExemption07 by using the Get-AzPolicyExemption cmdlet. The command stores that object in the $PolicyExemption variable. The final command updates the expiration date time for the policy exemption on the default subscription.
$PolicyExemption = Get-AzPolicyExemption -Name 'PolicyExemption07'
Update-AzPolicyExemption -Id $PolicyExemption.Id -ClearExpiration
The first command gets the policy exemption named PolicyExemption07 by using the Get-AzPolicyExemption cmdlet. The command stores that object in the $PolicyExemption variable. The second command clears the expiration date time for the policy exemption on the default subscription. The updated exemption will never expire.
$PolicyExemption = Get-AzPolicyExemption -Name 'PolicyExemption07'
Update-AzPolicyExemption -Id $PolicyExemption.Id -ExemptionCategory Mitigated
The first command gets the policy exemption named PolicyExemption07 by using the Get-AzPolicyExemption cmdlet. The command stores that object in the $PolicyExemption variable. The second command updates the expiration category for the policy exemption on the default subscription. The updated exemption will never expire.
The first command gets the current date time by using the Get-Date cmdlet and add 1 month to the current date time The command stores that object in the $NextMonth variable. The second command gets the policy exemption named PolicyExemption07 by using the Get-AzPolicyExemption cmdlet. The command stores that object in the $PolicyExemption variable. The final command updates the expiration date time for the policy exemption on the default subscription.
$ResourceSelector = @{Name = "MyLocationSelector"; Selector = @(@{Kind = "resourceLocation"; NotIn = @("eastus", "eastus2")})}
Update-AzPolicyExemption -Name 'VirtualMachineExemption' -ResourceSelector $ResourceSelector
The first command creates a resource selector object that will be used to specify the exemption should only apply to resources in locations other than East US or East US 2 and stores it in the $ResourceSelector variable. The final command updates the policy exemption named VirtualMachineExemption with the resource selector specified by $ResourceSelector.
$PolicyExemption = Get-AzPolicyExemption -Name 'PolicyExemption07' -BackwardCompatible
Set-AzPolicyExemption -Id $PolicyExemption.ResourceId -ClearExpiration -BackwardCompatible
The first command gets the policy exemption named PolicyExemption07 by using the Get-AzPolicyExemption cmdlet. The command stores that object in the $PolicyExemption variable. The second command clears the expiration date time for the policy exemption on the default subscription. The updated exemption will never expire.
The option whether validate the exemption is at or under the assignment scope.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
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 |
Indicates whether to clear the expiration date and time of the policy exemption.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
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 |
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 |
This message will be part of response in case of policy violation.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
The display name of the policy assignment.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
The policy exemption category
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of the policy exemption.
Type: | Nullable<T>[DateTime] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
Type: | String |
Aliases: | ResourceId |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Type: | IPolicyExemption |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
The policy assignment 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 |
The name of the policy exemption.
Type: | String |
Aliases: | PolicyExemptionName |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
The policy definition reference ID list when the associated policy assignment is for a policy set (initiative).
Type: | String[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
The resource selector list to filter policies by resource properties.
Type: | IResourceSelector[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
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}'
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
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 |
Nullable<T>[[System.DateTime, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
String[]
ALIASES
Set-AzPolicyExemption
Azure PowerShell feedback
Azure PowerShell is an open source project. Select a link to provide feedback: