Set-AzureRmRecoveryServicesBackupProtectionPolicy
Modifies a Backup protection policy.
Warning
The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.
Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.
Syntax
Set-AzureRmRecoveryServicesBackupProtectionPolicy
[-Policy] <PolicyBase>
[[-RetentionPolicy] <RetentionPolicyBase>]
[[-SchedulePolicy] <SchedulePolicyBase>]
[-VaultId <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Set-AzureRmBackupProtectionPolicy cmdlet modifies an existing Azure Backup protection policy. You can modify the Backup schedule and retention policy components. Any changes you make affect the backup and retention of the items associated with the policy. Set the vault context by using the Set-AzureRmRecoveryServicesVaultContext cmdlet before you use the current cmdlet.
Examples
Example 1: Modify a Backup protection policy
PS C:\>$SchPol = Get-AzureRmRecoveryServicesBackupSchedulePolicyObject -WorkloadType "AzureVM"
PS C:\> $SchPol.ScheduleRunTimes.RemoveAll()
PS C:\> $DT = Get-Date
PS C:\> $SchPol.ScheduleRunTimes.Add($DT.ToUniversalTime())
PS C:\> $RetPol = Get-AzureRmRecoveryServicesBackupRetentionPolicyObject -WorkloadType "AzureVM"
PS C:\> $RetPol.DailySchedule.DurationCountInDays = 365
PS C:\> $Pol = Get-AzureRmRecoveryServicesBackupProtectionPolicy -Name "NewPolicy"
PS C:\> Set-AzureRmRecoveryServicesBackupProtectionPolicy -Policy $Pol -SchedulePolicy $SchPol -RetentionPolicy $RetPol
The first command gets a base SchedulePolicy object, and then stores it in the $SchPol variable. The second command removes all scheduled run times from the schedule policy in $SchPol. The third command uses the Get-Date cmdlet to get the current date and time, and then stores it in the $DT variable. The fourth command adds the date and time in $DT to the schedule run time for the schedule policy. The fifth command gets a base retention policy object, and then stores it in the $RetPol variable. The sixth command sets the retention duration to 365 days. The seventh command gets the Backup protection policy named NewPolicy, and then stores it in the $Pol variable. The final command modifies the Backup protection policy in $Pol using schedule policy in $SchPol and the retention policy in $RetPol.
Parameters
-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: | AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Policy
Specifies the Backup protection policy that this cmdlet modifies. To obtain a BackupProtectionPolicy object, use the Get-AzureRmRecoveryServicesBackupProtectionPolicy cmdlet.
Type: | PolicyBase |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-RetentionPolicy
Specifies the base retention policy. To obtain a RetentionPolicy object, use the Get-AzureRmRecoveryServicesBackupRetentionPolicyObject cmdlet.
Type: | RetentionPolicyBase |
Position: | 2 |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SchedulePolicy
Specifies the base schedule policy object. To obtain a SchedulePolicy object, use the Get-AzureRmRecoveryServicesBackupSchedulePolicyObject object.
Type: | SchedulePolicyBase |
Position: | 3 |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-VaultId
ARM ID of the Recovery Services Vault.
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
Parameters: Policy (ByValue)
Parameters: VaultId (ByValue)