Set-AzPolicyExemption
Modifies a policy exemption.
Syntax
Set-AzPolicyExemption
-Name <String>
[-Scope <String>]
[-DisplayName <String>]
[-Description <String>]
[-ExemptionCategory <String>]
[-PolicyDefinitionReferenceId <String[]>]
[-ExpiresOn <DateTime>]
[-ClearExpiration]
[-Metadata <String>]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzPolicyExemption
-Id <String>
[-DisplayName <String>]
[-Description <String>]
[-ExemptionCategory <String>]
[-PolicyDefinitionReferenceId <String[]>]
[-ExpiresOn <DateTime>]
[-ClearExpiration]
[-Metadata <String>]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzPolicyExemption
[-DisplayName <String>]
[-Description <String>]
[-ExemptionCategory <String>]
[-PolicyDefinitionReferenceId <String[]>]
[-ExpiresOn <DateTime>]
[-ClearExpiration]
[-Metadata <String>]
-InputObject <PsPolicyExemption>
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Set-AzPolicyExemption cmdlet modifies a policy exemption. Specify an exemption by ID or by name and scope.
Examples
Example 1: Update the display name
$ResourceGroup = Get-AzResourceGroup -Name 'ResourceGroup11'
$PolicyExemption = Get-AzPolicyExemption -Name 'PolicyExemption07' -Scope $ResourceGroup.ResourceId
Set-AzPolicyExemption -Id $PolicyExemption.ResourceId -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.
Example 2: Update the expiration date time
$NextMonth = (Get-Date).AddMonths(1)
$PolicyExemption = Get-AzPolicyExemption -Name 'PolicyExemption07'
Set-AzPolicyExemption -Id $PolicyExemption.ResourceId -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.
Example 3: Clear the expiration date time
$PolicyExemption = Get-AzPolicyExemption -Name 'PolicyExemption07'
Set-AzPolicyExemption -Id $PolicyExemption.ResourceId -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.
Example 4: Update the expiration category
$PolicyExemption = Get-AzPolicyExemption -Name 'PolicyExemption07'
Set-AzPolicyExemption -Id $PolicyExemption.ResourceId -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.
Parameters
-ApiVersion
When set, indicates the version of the resource provider API to use. If not specified, the API version is automatically determined as the latest available.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ClearExpiration
If set, this switch clears the expiration date and time on the updated policy exemption.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
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 credentials, account, tenant, and subscription used for communication with Azure.
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Description
The description for the updated policy exemption.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DisplayName
The display name for the updated policy exemption.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ExemptionCategory
The policy exemption category of the updated policy exemption. Possible values are Waiver and Mitigated.
Type: | String |
Accepted values: | Waiver, Mitigated |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ExpiresOn
The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of the updated policy exemption.
Type: | Nullable<T>[DateTime] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Id
The fully qualified policy exemption Id to update, including the scope, e.g. /subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}.
Type: | String |
Aliases: | ResourceId |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-InputObject
The policy exemption object to update that was output from another cmdlet.
Type: | PsPolicyExemption |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Metadata
The metadata for the updated policy exemption. This can either be a path to a file containing the metadata JSON, or the metadata as a JSON string.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Name
The name of the policy exemption to update.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-PolicyDefinitionReferenceId
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 |
-Pre
When set, indicates that the cmdlet should use pre-release API versions when automatically determining which version to use.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Scope
The scope of the updated policy exemption, e.g. /providers/managementGroups/{managementGroupName}, defaults to current subscription.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
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
String[]
Nullable<T>[[System.DateTime, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]