Edit

Share via


Edit-AzDataProtectionPolicyRetentionRuleClientObject

Adds or removes Retention Rule to existing Policy

Syntax

RemoveRetention (Default)

Edit-AzDataProtectionPolicyRetentionRuleClientObject
    -Policy <IBackupPolicy>
    -Name <RetentionRuleName>
    [-RemoveRule]
    [<CommonParameters>]

AddRetention

Edit-AzDataProtectionPolicyRetentionRuleClientObject
    -Policy <IBackupPolicy>
    -Name <RetentionRuleName>
    -IsDefault <Boolean>
    -LifeCycles <ISourceLifeCycle[]>
    [-OverwriteLifeCycle <Boolean>]
    [<CommonParameters>]

Description

Adds or removes Retention Rule to existing Policy

Examples

Example 1: Add Weekly Retention Rule

$pol = Get-AzDataProtectionPolicyTemplate
$lifecycle = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore OperationalStore -SourceRetentionDurationType Weeks -SourceRetentionDurationCount 5
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $pol -Name Weekly -LifeCycles $lifecycle -IsDefault $false
DatasourceType            ObjectType
--------------            ----------
{Microsoft.Compute/disks} BackupPolicy

The first command gets the default policy template. The second command creates a weekly lifecycle object. The third command adds a weekly retention rule to the default policy.

Example 2: Remove Weekly Retention Rule

Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $pol -Name Weekly -RemoveRule
DatasourceType            ObjectType
--------------            ----------
{Microsoft.Compute/disks} BackupPolicy

This command removes weekly retention rule if it exists in given backup policy.

Parameters

-IsDefault

Specifies if retention rule is default retention rule.

Parameter properties

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

Parameter sets

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

-LifeCycles

Life cycles associated with the retention rule. To construct, see NOTES section for LIFECYCLES properties and create a hash table.

Parameter properties

Type:

ISourceLifeCycle[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

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

-Name

Retention Rule Name

Parameter properties

Type:RetentionRuleName
Default value:None
Accepted values:Default, Daily, Weekly, Monthly, Yearly
Supports wildcards:False
DontShow:False

Parameter sets

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

-OverwriteLifeCycle

Specifies whether to modify an existing LifeCycle.

Parameter properties

Type:

Nullable<T>[Boolean]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

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

-Policy

Backup Policy Object To construct, see NOTES section for POLICY properties and create a hash table.

Parameter properties

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

Parameter sets

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

-RemoveRule

Specifies whether to remove the retention rule.

Parameter properties

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

Parameter sets

RemoveRetention
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
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.

Outputs

IBackupPolicy